Skip to content

Commit

Permalink
Fix docker files
Browse files Browse the repository at this point in the history
  • Loading branch information
89Q12 committed Feb 2, 2024
1 parent d7e34c1 commit 752913d
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
postgres-data/
19 changes: 0 additions & 19 deletions backend/docker-compose.yml

This file was deleted.

31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3.8'
services:
database:
image: postgres:15
environment:
POSTGRES_USER: cardinal
POSTGRES_PASSWORD: postgres
POSTGRES_DB: cardinal
ports:
- "5432:5432"
volumes:
- ./postgres-data:/var/lib/postgresql/data
bot:
build:
context: ./backend
dockerfile: ./Dockerfile
#uncomment below on first run
# command: yarn run prisma db push
depends_on:
- database
nginx:
build:
context: ./frontend
dockerfile: ./Dockerfile
ports:
- "1300:80"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
depends_on:
- bot

5 changes: 5 additions & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
dist
18 changes: 18 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

# Stage 1: Build the Node.js project
FROM node:20 as build

WORKDIR /app

COPY . .
RUN yarn install --network-timeout 100000 \
&& yarn run build

# Stage 2: Serve the built files using Nginx
FROM nginx:latest

COPY --from=build /app/dist /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
20 changes: 20 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

server {
listen 80;

root /usr/share/nginx/html;

# Bot API reverse proxy
location /api {
proxy_pass http://bot:3000;
}

location / {
try_files $uri @rewrites;
}

location @rewrites {
rewrite ^(.+)$ /index.html last;
}

}

0 comments on commit 752913d

Please sign in to comment.