Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
Improved Docker Compose file for production deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianLeChat committed Aug 25, 2023
1 parent 8e10c9a commit ec5cd05
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
**/*.md
**/.env*.local
**/.next
**/.git*
**/.dockerignore
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# https://hub.docker.com/_/node
FROM node:lts-alpine

# Add cURL for health check
RUN apk --no-cache add curl

# Set the working directory to the website files
WORKDIR /usr/src/app

Expand Down Expand Up @@ -33,9 +36,6 @@ RUN npm run build
# Change the ownership of the build files
RUN chown -R node:node /usr/src/app/.next

# Remove all development dependencies
RUN npm prune --production

# Use non-root user
USER node

Expand Down
26 changes: 20 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.9"
version: "3.8"

networks:
domego:
Expand All @@ -8,7 +8,6 @@ services:
# https://hub.docker.com/_/mongo
mongo:
image: mongo:latest
container_name: database
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
Expand All @@ -20,12 +19,27 @@ services:
# https://github.com/FlorianLeChat/Domego
node:
image: domego
container_name: website
restart: unless-stopped
restart: always
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000"]
retries: 3
timeout: 5s
networks:
- domego
deploy:
resources:
limits:
cpus: "1"
memory: 512M
reservations:
cpus: "0.25"
memory: 128M
restart_policy:
window: 60s
condition: on-failure
max_attempts: 5
build:
context: .
dockerfile: ./Dockerfile
networks:
- domego
ports:
- 3000:3000

0 comments on commit ec5cd05

Please sign in to comment.