Skip to content

Commit 6ec0535

Browse files
docker overhaul
1 parent 6f01970 commit 6ec0535

4 files changed

Lines changed: 61 additions & 19 deletions

File tree

.github/workflows/deploy-staging.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ jobs:
3434
cd /home/deploy/aktiv
3535
3636
# Ensure env files exist
37-
if [ ! -f backend/.env.staging ]; then
38-
echo "ERROR: backend/.env.staging not found"
37+
if [ ! -f .env.staging ]; then
38+
echo "ERROR: .env.staging not found"
3939
exit 1
4040
fi
4141
42-
if [ ! -f frontend/.env.staging ]; then
43-
echo "ERROR: frontend/.env.staging not found"
42+
if [ ! -f backend/.env.staging ]; then
43+
echo "ERROR: backend/.env.staging not found"
4444
exit 1
4545
fi
4646
@@ -49,6 +49,9 @@ jobs:
4949
git checkout staging || git checkout -b staging
5050
git reset --hard origin/staging
5151
52+
# Load staging secrets for compose build args
53+
export $(cat /home/deploy/aktiv/.env.staging | xargs)
54+
5255
# Rebuild containers cleanly
5356
# Note: composer install & dump-autoload are already handled in the Dockerfile
5457
docker compose -f docker-compose.yml -f docker-compose.staging.yml down

docker-compose.staging.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@ services:
77

88
# ─── Frontend ─────────────────────────────────────────────────────────────
99
frontend:
10-
env_file: !reset
11-
- ./frontend/.env.staging
12-
user: "root"
13-
command: >
14-
sh -c "npm install &&
15-
npm run build &&
16-
node .output/server/index.mjs"
10+
build:
11+
context: ./frontend
12+
dockerfile: Dockerfile
13+
args:
14+
NUXT_PUBLIC_API_BASE: https://staging.aktivhub.app/api
15+
NUXT_API_BASE_INTERNAL: http://nginx/api
16+
NUXT_PUBLIC_REVERB_HOST: staging.aktivhub.app
17+
NUXT_PUBLIC_REVERB_PORT: "443"
18+
NUXT_PUBLIC_REVERB_SCHEME: https
19+
NUXT_PUBLIC_REVERB_KEY: ${NUXT_PUBLIC_REVERB_KEY}
20+
NUXT_PUBLIC_GOOGLE_MAPS_KEY: ${NUXT_PUBLIC_GOOGLE_MAPS_KEY}
21+
NUXT_CLARITY_ID: ${NUXT_CLARITY_ID}
1722
restart: unless-stopped
1823

1924
# ─── Backend ──────────────────────────────────────────────────────────────

docker-compose.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,10 @@ services:
1616

1717
# ─── Nuxt 3 frontend ───────────────────────────────────────────────────────
1818
frontend:
19-
image: node:20-alpine
19+
build:
20+
context: ./frontend
21+
dockerfile: Dockerfile
2022
container_name: aktiv_frontend
21-
working_dir: /app
22-
user: "${UID:-1000}:${GID:-1000}"
23-
volumes:
24-
- ./frontend:/app
25-
env_file:
26-
- ./frontend/.env
27-
command: sh -c "npm install && npm run dev"
2823
expose:
2924
- "3000"
3025
restart: unless-stopped

frontend/Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM node:20-alpine
2+
3+
WORKDIR /app
4+
5+
# Copy package files first for better layer caching
6+
COPY package*.json ./
7+
8+
RUN npm ci --production=false
9+
10+
# Copy the rest of the app
11+
COPY . .
12+
13+
# Build arg declarations — these get baked in at build time
14+
ARG NUXT_PUBLIC_API_BASE \
15+
NUXT_PUBLIC_REVERB_KEY \
16+
NUXT_PUBLIC_REVERB_HOST \
17+
NUXT_PUBLIC_REVERB_PORT \
18+
NUXT_PUBLIC_REVERB_SCHEME \
19+
NUXT_PUBLIC_GOOGLE_MAPS_KEY \
20+
NUXT_CLARITY_ID \
21+
NUXT_API_BASE_INTERNAL
22+
23+
ENV NUXT_PUBLIC_API_BASE=$NUXT_PUBLIC_API_BASE \
24+
NUXT_PUBLIC_REVERB_KEY=$NUXT_PUBLIC_REVERB_KEY \
25+
NUXT_PUBLIC_REVERB_HOST=$NUXT_PUBLIC_REVERB_HOST \
26+
NUXT_PUBLIC_REVERB_PORT=$NUXT_PUBLIC_REVERB_PORT \
27+
NUXT_PUBLIC_REVERB_SCHEME=$NUXT_PUBLIC_REVERB_SCHEME \
28+
NUXT_PUBLIC_GOOGLE_MAPS_KEY=$NUXT_PUBLIC_GOOGLE_MAPS_KEY \
29+
NUXT_CLARITY_ID=$NUXT_CLARITY_ID \
30+
NUXT_API_BASE_INTERNAL=$NUXT_API_BASE_INTERNAL
31+
32+
RUN npm run build
33+
34+
EXPOSE 3000
35+
36+
ENV HOST=0.0.0.0 \
37+
PORT=3000
38+
39+
CMD ["node", ".output/server/index.mjs"]

0 commit comments

Comments
 (0)