This commit is contained in:
@@ -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
@@ -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
|
||||
```
|
||||
|
||||
@@ -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"]
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
name: build-and-push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.shihaam.dev
|
||||
username: ${{ secrets.DOCKER_REGISTRY_USER }}
|
||||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Build and push
|
||||
env:
|
||||
VITE_API_TARGET: ${{ vars.VITE_API_TARGET }}
|
||||
run: docker compose -f .build/prod/compose.yml build --push
|
||||
Reference in New Issue
Block a user