forked from aerabi/events
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dockerfiles and docker-compose config (aerabi#13)
- Loading branch information
Showing
7 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PORT=8000 | ||
MONGODB_URI=mongodb://db:27017 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Builder container to compile typescript | ||
FROM node:lts-alpine AS build | ||
WORKDIR /usr/src/app | ||
|
||
# Install dependencies | ||
COPY package.json . | ||
COPY package-lock.json . | ||
RUN npm ci | ||
|
||
# Copy the application source | ||
COPY . . | ||
# Build typescript | ||
RUN npm run build | ||
|
||
|
||
|
||
FROM node:lts-alpine | ||
WORKDIR /app | ||
COPY package.json . | ||
COPY package-lock.json . | ||
COPY .env.production .env | ||
|
||
RUN npm ci --production | ||
|
||
COPY --from=build /usr/src/app/dist /app | ||
|
||
EXPOSE 8000 | ||
CMD [ "node", "index.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
services: | ||
frontend: | ||
build: | ||
context: "./frontend/events" | ||
dockerfile: "./Dockerfile" | ||
backend: | ||
build: | ||
context: "./backend" | ||
dockerfile: "./Dockerfile" | ||
db: | ||
image: mongo:latest | ||
ports: | ||
- 27017:27017 | ||
proxy: | ||
image: nginx:stable-alpine | ||
environment: | ||
- NGINX_ENVSUBST_TEMPLATE_SUFFIX=.conf | ||
- NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx | ||
volumes: | ||
- ${PWD}/nginx.conf:/etc/nginx/templates/nginx.conf.conf | ||
ports: | ||
- 80:80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Builder container to compile typescript | ||
FROM node:lts-alpine AS build | ||
WORKDIR /usr/src/app | ||
|
||
# Install dependencies | ||
COPY package.json . | ||
COPY package-lock.json . | ||
RUN npm ci | ||
|
||
# Copy the application source | ||
COPY . . | ||
# Build typescript | ||
RUN npm run build | ||
|
||
|
||
|
||
FROM nginx:stable-alpine | ||
|
||
COPY nginx.conf /etc/nginx/nginx.conf | ||
COPY --from=build /usr/src/app/dist/events /usr/share/nginx/html | ||
|
||
EXPOSE 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
events{} | ||
http { | ||
include /etc/nginx/mime.types; | ||
server { | ||
listen 80; | ||
server_name localhost; | ||
root /usr/share/nginx/html; | ||
index index.html; | ||
location / { | ||
try_files $uri $uri/ /index.html; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
user nginx; | ||
worker_processes 1; | ||
|
||
error_log /var/log/nginx/error.log debug; | ||
|
||
events {} | ||
http { | ||
server { | ||
listen 80; | ||
location / { | ||
# Route frontend stuff | ||
error_page 404 /; | ||
proxy_intercept_errors on; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_set_header X-Forwarded-Host $host; | ||
proxy_set_header X-Forwarded-Port $server_port; | ||
proxy_pass http://frontend:80/; | ||
} | ||
location ~ ^/(api) { | ||
# Route api requests to api server | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_set_header X-Forwarded-Host $host; | ||
proxy_set_header X-Forwarded-Port $server_port; | ||
include uwsgi_params; | ||
proxy_pass http://backend:8000; | ||
} | ||
} | ||
} |