Skip to content

Commit

Permalink
build: dockerize front and backend
Browse files Browse the repository at this point in the history
  • Loading branch information
SverreNystad committed Jul 17, 2024
1 parent 084bcdb commit 14ba1e8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
15 changes: 14 additions & 1 deletion backend/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,24 @@
services:
backend-board-master:
build:
context: .
context: ./backend
dockerfile: Dockerfile
image: board-master/backend:latest
ports:
- 8080:8080
container_name: backend-board-master
restart: always

frontend-board-master:
build:
context: ./frontend
dockerfile: Dockerfile
image: board-master/frontend:latest
ports:
- 3000:80
container_name: frontend-board-master
restart: always


# The commented out section below is an example of how to define a PostgreSQL
# database that your application can use. `depends_on` tells Docker Compose to
Expand Down
13 changes: 13 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Frontend Dockerfile
FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

FROM nginx:alpine
COPY --from=build /app/build /usr/share/nginx/html

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
17 changes: 17 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
server {
listen 80;
server_name localhost;

root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri $uri/ /index.html;
}

location /static/ {
alias /usr/share/nginx/html/static/;
}

error_page 404 /index.html;
}

0 comments on commit 14ba1e8

Please sign in to comment.