Skip to content

Commit

Permalink
add docker entrypoint to try and run backend before frontend build. (…
Browse files Browse the repository at this point in the history
…#403)
  • Loading branch information
Magnus Alexander Strømseng authored and GitHub committed May 9, 2024
1 parent 34b916c commit 974e2d4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
10 changes: 7 additions & 3 deletions Dockerfile-frontend
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
FROM node:20
WORKDIR /usr/src/app/frontend
EXPOSE 3000

COPY frontend /usr/src/app/frontend
COPY .env.production /usr/src/app/frontend/.env.production
RUN npm i
RUN npm run build
EXPOSE 3000
CMD ["npm", "run", "start"]

COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh

ENTRYPOINT ["/bin/sh", "/docker-entrypoint.sh"]
52 changes: 27 additions & 25 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
version: "3.3"
services:
backend:
restart: unless-stopped
volumes:
- type: bind
source: /var/data/
target: /var/data/
- type: bind
source: /var/data/outreachuploads
target: /usr/src/app/backend/public/uploads
build:
context: .
dockerfile: Dockerfile-backend
image: backend:outreach
ports:
- "1337:1337"
environment:
- NODE_ENV=production
backend:
restart: unless-stopped
volumes:
- type: bind
source: /var/data/
target: /var/data/
- type: bind
source: /var/data/outreachuploads
target: /usr/src/app/backend/public/uploads
build:
context: .
dockerfile: Dockerfile-backend
image: backend:outreach
ports:
- "1337:1337"
environment:
- NODE_ENV=production

frontend:
restart: unless-stopped
build:
context: .
dockerfile: Dockerfile-frontend
image: frontend:outreach
ports:
- "3000:3000"
frontend:
depends_on:
- backend
restart: unless-stopped
build:
context: .
dockerfile: Dockerfile-frontend
image: frontend:outreach
ports:
- "3000:3000"
7 changes: 7 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Build the Next site including SSG
npm run build

# Start the production server
exec npm run start

0 comments on commit 974e2d4

Please sign in to comment.