This commit is contained in:
Joshua Perry 2024-10-14 18:08:21 +01:00
commit 80f2dabfb9
4 changed files with 52 additions and 0 deletions

13
backend.Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM openjdk:latest AS builder
#TODO: change latest to same version as project
COPY backend/ /backend/
# TODO: change backend to the name of application folder
WORKDIR /backend/
RUN mvn clean package -DskipTests
FROM openjdk:latest
COPY --from=builder backend/target/example.jar app.jar
#TODO: change example.jar to application name
CMD ["java", "-jar", "app.jar"]

20
docker-compose.yml Normal file
View File

@ -0,0 +1,20 @@
services:
frontend:
build: "./frontend.Dockerfile"
ports:
- 3000:3000
backend:
build: "./backend.Dockerfile"
ports:
- 4000:4000
database:
image: "mongo:latest"
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: "root"
MONGO_INITDB_ROOT_PASSWORD: "password"
volumes: database:/data/db
volumes:
database:

5
frontend.Dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM node:latest
#TODO: change latest to application version
COPY backend/ /backend/
RUN npm install
CMD ["npm", "run", "dev"]

14
nginx.conf Normal file
View File

@ -0,0 +1,14 @@
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}