Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./src/node_modules
14 changes: 13 additions & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# ADD DOCKERFILE CONTENTS HERE
FROM node:22-slim

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 3000

CMD ["npm", "start"]
70 changes: 69 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1 +1,69 @@
# ADD DOCKER-COMPOSE CONTENT HERE
volumes:
mongodb_data:
driver: local
redis_data:
driver: local

networks:
techstach:
driver: bridge
services:
nginx:
container_name: techstach-nginx
build:
context: ./nginx
dockerfile: Dockerfile
ports:
- 8088:80
networks:
- techstach
depends_on:
- db
- app
- redis

app:
container_name: techstach-app
build:
context: ./backend
dockerfile: Dockerfile
ports:
- 3000:3000
networks:
- techstach
environment:
- MONGODB_URI=mongodb://db:27017/techstach
- REDIS_HOST=techstach-redis
- REDIS_PORT=6379
- NODE_ENV=development
- PORT=3000
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
depends_on:
- db
db:
container_name: techstach-mongodb
image: mongo:latest
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
ports:
- 27017:27017
networks:
- techstach
volumes:
- mongodb_data:/data/db

redis:
container_name: techstach-redis
image: redis:alpine
ports:
- 6379:6379
networks:
- techstach
volumes:
- redis_data:/data
7 changes: 7 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from nginx:stable-alpine

COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
18 changes: 17 additions & 1 deletion nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# ADD NGINX CONFIGS HERE
server {
listen 80;
server_name localhost;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;

location / {
proxy_pass http://app:3000;
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header Scheme $scheme;
proxy_set_header SERVER_PORT $server_port;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
}
}