build backend and auto build and push everything
build-and-push / build (push) Canceled after 0s

This commit is contained in:
2026-08-01 00:27:38 +05:00
parent 533faabab9
commit 2f66c04d1b
7 changed files with 102 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
FROM python:3.12-slim
WORKDIR /var/www/html/
CMD pip install -r requirements.txt && uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
+33 -9
View File
@@ -1,16 +1,40 @@
## Production deployment
it is assumed that you will be using backend on the same machine, so this compose is for both services
Both services build from the repo root (monorepo). The frontend container runs
nginx, which serves the built SPA at `/` and reverse-proxies `/api` to the
backend container. Only the frontend port needs to be published — the backend
is reached internally over the compose network as `backend:8000`.
```
host.com/ -> frontend (nginx static SPA)
host.com/api/... -> backend (FastAPI, /api prefix stripped)
```
### Build & run
```sh
cp .env.example .env # VITE_API_TARGET (dev proxy only)
cp ../../backend/.env.example ../../backend/.env # DB creds, API_KEY, etc.
docker compose -f .build/prod/compose.yml up -d --build
```
The portal is then available on `http://HOST:8000`.
### Running from published images
```yml
services:
frontend:
hostname: frontend
image: git.shihaam.dev/sarlink/radui
ports:
- 8000:80
backend:
hostname: backend
image: git.shihaam.dev/sarlink/radapi
ports:
- 8001:80
image: git.shihaam.dev/sarlink/radadmin/backed
env_file:
- backend.env
frontend:
hostname: frontend
image: git.shihaam.dev/sarlink/radadmin/frontend
ports:
- 8000:80
depends_on:
- backend
```
+7
View File
@@ -0,0 +1,7 @@
FROM python:3.12-slim
WORKDIR /app
COPY backend/ .
RUN pip install --no-cache-dir -r requirements.txt
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
+8 -2
View File
@@ -1,9 +1,15 @@
services:
frontend:
build:
context: ../../frontend
context: ../../
dockerfile: .build/prod/frontend.Dockerfile
args:
VITE_API_TARGET: ${VITE_API_TARGET}
hostname: frontend
image: git.shihaam.dev/sarlink/radui
image: git.shihaam.dev/sarlink/radadmin/backend
backend:
build:
context: ../../
dockerfile: .build/prod/backend.Dockerfile
hostname: backend
image: git.shihaam.dev/sarlink/radadmin/frontend
+1
View File
@@ -10,3 +10,4 @@ RUN echo VITE_API_TARGET=$VITE_API_TARGET > .env \
FROM nginx
COPY --from=frontendbuilder /var/www/html/dist /usr/share/nginx/html
COPY .build/prod/nginx.conf /etc/nginx/conf.d/default.conf
+19
View File
@@ -0,0 +1,19 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location /api/ {
proxy_pass http://backend:8000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location / {
try_files $uri $uri/ /index.html;
}
}