Skip to content

Commit 835e763

Browse files
Deploy Locally
1 parent 660fb1d commit 835e763

File tree

10 files changed

+265
-1
lines changed

10 files changed

+265
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
firebase-auth
2+
mongodb-data
3+
postgres-data
4+
.env

deployment/Dockerfile-executor

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# To build a Docker image from this file, run from the root directory:
2+
23
# docker build -f deployment/Dockerfile-executor -t peerprep-executor .
34

45
FROM nixos/nix:2.3.12
56

67
# Environment variables
8+
79
ENV APP_ROOT /executor
810

911
WORKDIR $APP_ROOT
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# To build a Docker image from this file, run from the root directory:
2+
3+
# docker build -f deployment/Dockerfile-executor -t peerprep-executor .
4+
5+
FROM nixos/nix:2.3.12
6+
7+
# Environment variables
8+
9+
ENV APP_ROOT /executor
10+
11+
WORKDIR $APP_ROOT
12+
COPY executor .
13+
14+
RUN echo "filter-syscalls = false" >> /etc/nix/nix.conf
15+
RUN nix-channel --update
16+
RUN nix-env -iA nixpkgs.shadow nixpkgs.gcc12 nixpkgs.python3Minimal nixpkgs.jdk19_headless
17+
RUN nix-env -if default.nix
18+
19+
RUN groupadd -g 1300 -r peerprep
20+
RUN useradd -g 1300 -u 1500 -r executor
21+
22+
EXPOSE 9000
23+
24+
CMD ["executor"]

deployment/Dockerfile-frontend

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
# To build a Docker image from this file, run from the root directory:
2+
23
# docker build -f deployment/Dockerfile-frontend -t peerprep-frontend .
34

45
# Intermediate image for building the Next app
6+
57
FROM node:18.17.1
68

79
# Environment variables
10+
811
ENV APP_ROOT /frontend
912

1013
# Copy source code into container
14+
1115
RUN mkdir --parents $APP_ROOT
1216
WORKDIR $APP_ROOT
1317
COPY frontend .
1418

1519
# Install dependencies
20+
1621
RUN yarn install --frozen-lockfile
1722

1823
# Build app
24+
1925
RUN yarn build
2026

2127
# Expose port
28+
2229
EXPOSE 3000
2330

2431
# Final image for running the Next app
32+
2533
CMD ["yarn", "start"]

deployment/Dockerfile-innkeeper

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
# To build a Docker image from this file, run from the root directory:
2+
23
# docker build -f deployment/Dockerfile-innkeeper -t peerprep-innkeeper-service .
34

45
# Intermediate image for building the Next app
6+
57
FROM node:18.17.1
68

79
# Environment variables
10+
811
ENV APP_ROOT /innkeeper
912

1013
# Copy source code into container
14+
1115
RUN mkdir --parents $APP_ROOT
1216
WORKDIR $APP_ROOT
1317
COPY innkeeper .
1418

1519
# Install dependencies
20+
1621
RUN yarn install --frozen-lockfile
1722

1823
# Build app
24+
1925
RUN yarn build
2026

2127
# Expose port
28+
2229
EXPOSE 4100
2330

2431
# Final image for running the Socket.IO app
32+
2533
CMD ["yarn", "start"]

deployment/Dockerfile-nginx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN rm -f /etc/nginx/conf.d/* /etc/nginx/sites-enabled/*
66

77
# Copy NGINX config
88
COPY deployment/nginx/nginx.conf /etc/nginx
9-
COPY deployment/nginx/sites-enabled/* /etc/nginx/sites-enabled/
9+
COPY deployment/nginx/sites-enabled/peerprep.sivarn.com /etc/nginx/sites-enabled/peerprep.sivarn.com
1010

1111
# Expose ports
1212
EXPOSE 80

deployment/Dockerfile-nginx-local

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Use nginx to serve the app
2+
FROM nginx:stable
3+
4+
# Delete NGINX defaults
5+
RUN rm -f /etc/nginx/conf.d/* /etc/nginx/sites-enabled/*
6+
7+
# Copy NGINX config
8+
COPY deployment/nginx/nginx.conf /etc/nginx
9+
COPY deployment/nginx/sites-enabled/localhost /etc/nginx/sites-enabled/locahost
10+
11+
# Expose ports
12+
EXPOSE 80
13+
EXPOSE 443
14+
15+
# Add a script containing the main command to be executed
16+
COPY deployment/scripts/cmd-nginx.sh /usr/bin/
17+
CMD ["cmd-nginx.sh"]

deployment/Dockerfile-questions

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
# To build a Docker image from this file, run from the root directory:
2+
23
# docker build -f deployment/Dockerfile-questions -t peerprep-questions-service .
34

45
# Intermediate image for building the Next app
6+
57
FROM node:18.17.1
68

79
# Environment variables
10+
811
ENV APP_ROOT /questions
912

1013
# Copy source code into container
14+
1115
RUN mkdir --parents $APP_ROOT
1216
WORKDIR $APP_ROOT
1317
COPY questions .
1418

1519
# Install dependencies
20+
1621
RUN yarn install --frozen-lockfile
1722

1823
# Build app
24+
1925
RUN yarn build
2026

2127
# Expose port
28+
2229
EXPOSE 4000
2330

2431
# Final image for running the Express app
32+
2533
CMD ["yarn", "start"]
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# When searching for a virtual server by name, if name matches more than one of the specified variants, e.g.
2+
# both wildcard name and regular expression match, the first matching variant will be chosen, in the following
3+
# order of precedence:
4+
#
5+
# 1. exact name
6+
# 2. longest wildcard name starting with an asterisk, e.g. “*.example.org”
7+
# 3. longest wildcard name ending with an asterisk, e.g. “mail.*”
8+
# 4. first matching regular expression (in order of appearance in a configuration file)
9+
10+
server {
11+
listen 80;
12+
server_name localhost;
13+
14+
location / {
15+
proxy_pass http://peerprep-frontend:3000/;
16+
proxy_set_header Host $host;
17+
proxy_set_header X-Real-IP $remote_addr;
18+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19+
proxy_set_header X-Forwarded-Proto $scheme;
20+
}
21+
22+
location /api/v1/questions/ {
23+
proxy_pass http://peerprep-questions-service:4000/api/v1/questions/;
24+
proxy_set_header Host $host;
25+
proxy_set_header X-Real-IP $remote_addr;
26+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
27+
proxy_set_header X-Forwarded-Proto $scheme;
28+
}
29+
30+
location /api/v1/users/ {
31+
proxy_pass http://peerprep-users-service:6969/api/v1/users/;
32+
proxy_set_header Host $host;
33+
proxy_set_header X-Real-IP $remote_addr;
34+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
35+
proxy_set_header X-Forwarded-Proto $scheme;
36+
}
37+
38+
location /api/v1/innkeeper/ {
39+
proxy_pass http://peerprep-innkeeper-service:4100/api/v1/innkeeper/;
40+
proxy_set_header Host $host;
41+
proxy_http_version 1.1;
42+
proxy_set_header Upgrade $http_upgrade;
43+
proxy_set_header Connection "upgrade";
44+
proxy_set_header X-Real-IP $remote_addr;
45+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
46+
proxy_set_header X-Forwarded-Proto $scheme;
47+
}
48+
49+
location /api/v1/execute/ {
50+
include /etc/nginx/fastcgi_params;
51+
fastcgi_pass peerprep-executor-service:9000;
52+
}
53+
}
54+
55+
# Catch-all for unrecognised requests
56+
server {
57+
listen 80 default_server;
58+
server_name _;
59+
return 444;
60+
}

docker-compose.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
version: "3.8"
2+
3+
services:
4+
mongo:
5+
container_name: peerprep-mongo
6+
image: mongo
7+
restart: always
8+
volumes:
9+
- ./mongodb-data:/data/db
10+
networks:
11+
- peerprep-network
12+
expose:
13+
- "27017"
14+
15+
postgres:
16+
container_name: peerprep-postgres
17+
image: postgres
18+
restart: always
19+
volumes:
20+
- ./postgres-data:/var/lib/postgresql/data
21+
networks:
22+
- peerprep-network
23+
expose:
24+
- "5432"
25+
environment:
26+
POSTGRES_USER: ${POSTGRES_USER}
27+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
28+
29+
executor:
30+
image: peerprep-executor-service
31+
build:
32+
context: .
33+
dockerfile: deployment/Dockerfile-executor-local
34+
platform: linux/amd64
35+
container_name: peerprep-executor-service
36+
restart: always
37+
networks:
38+
- peerprep-network
39+
expose:
40+
- "9000"
41+
42+
innkeeper:
43+
image: peerprep-innkeeper-service
44+
build:
45+
context: .
46+
dockerfile: deployment/Dockerfile-innkeeper
47+
container_name: peerprep-innkeeper-service
48+
restart: always
49+
networks:
50+
- peerprep-network
51+
expose:
52+
- "4100"
53+
volumes:
54+
- ./firebase-auth:/firebase-auth
55+
environment:
56+
GOOGLE_APPLICATION_CREDENTIALS: ${GOOGLE_APPLICATION_CREDENTIALS}
57+
58+
questions:
59+
image: peerprep-questions-service
60+
build:
61+
context: .
62+
dockerfile: deployment/Dockerfile-questions
63+
container_name: peerprep-questions-service
64+
restart: always
65+
depends_on:
66+
- mongo
67+
networks:
68+
- peerprep-network
69+
expose:
70+
- "4000"
71+
volumes:
72+
- ./firebase-auth:/firebase-auth
73+
environment:
74+
GOOGLE_APPLICATION_CREDENTIALS: ${GOOGLE_APPLICATION_CREDENTIALS}
75+
MONGODB_URL: ${MONGODB_URL}
76+
BUCKET_NAME: ${BUCKET_NAME}
77+
USERS_SERVICE_URL: ${USERS_SERVICE_URL}
78+
INITIALIZATION_VECTOR: ${INITIALIZATION_VECTOR}
79+
ENCRYPTION_KEY: ${ENCRYPTION_KEY}
80+
81+
users:
82+
image: peerprep-users-service
83+
build:
84+
context: .
85+
dockerfile: deployment/Dockerfile-users
86+
container_name: peerprep-users-service
87+
restart: always
88+
depends_on:
89+
- postgres
90+
networks:
91+
- peerprep-network
92+
expose:
93+
- "6969"
94+
volumes:
95+
- ./firebase-auth:/firebase-auth
96+
environment:
97+
GOOGLE_APPLICATION_CREDENTIALS: ${GOOGLE_APPLICATION_CREDENTIALS}
98+
POSTGRES_URL: ${POSTGRES_URL}
99+
BUCKET_NAME: ${BUCKET_NAME}
100+
101+
frontend:
102+
image: peerprep-frontend
103+
build:
104+
context: .
105+
dockerfile: deployment/Dockerfile-frontend
106+
container_name: peerprep-frontend
107+
restart: always
108+
depends_on:
109+
- users
110+
- questions
111+
- innkeeper
112+
- executor
113+
networks:
114+
- peerprep-network
115+
expose:
116+
- "3000"
117+
118+
nginx:
119+
image: peerprep-nginx
120+
build:
121+
context: .
122+
dockerfile: deployment/Dockerfile-nginx-local
123+
container_name: peerprep-nginx
124+
restart: always
125+
depends_on:
126+
- frontend
127+
networks:
128+
- peerprep-network
129+
ports:
130+
- "80:80"
131+
132+
networks:
133+
peerprep-network:

0 commit comments

Comments
 (0)