Skip to content

Commit

Permalink
Dockerise frontend with nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
nknguyenhc committed Oct 1, 2024
1 parent 6b97a2d commit 934f424
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ services:
build: ./backend/user-service
ports:
- "3001:3001"

frontend:
build: ./frontend
ports:
- "80:80"
2 changes: 2 additions & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
node_modules/
23 changes: 23 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:20 AS build

WORKDIR /app

COPY package*.json .

RUN npm install

COPY ./src ./src

COPY ./public ./public

COPY .env .

COPY tsconfig.json .

RUN npm run build

FROM nginx:latest

COPY ./nginx /etc/nginx

COPY --from=build /app/build /app
12 changes: 12 additions & 0 deletions frontend/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
worker_processes auto;

error_log /var/log/nginx/error.log;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
include /etc/nginx/sites-enabled/*;
}
8 changes: 8 additions & 0 deletions frontend/nginx/sites-enabled/app.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server {
listen 80;
server_name localhost;

location / {
root /app;
}
}

0 comments on commit 934f424

Please sign in to comment.