feat: working docker

This commit is contained in:
Mateusz Pstrucha committed 2022-04-19 17:28:28 +02:00
1 parent 6e55829908
commit 1fb6a7608e
4 files changed
+46 -69

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
.git
node_modules
data
build
.vscode
.github
DockerFile
.dockerignore
.prettierrc
.gitignore
+6 -11
View File
@@ -1,12 +1,7 @@
FROM node:14-stretch AS build
WORKDIR /build
COPY package-lock.json package.json ./
RUN npm ci
FROM node:16
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install
COPY . .
FROM node:14-alpine AS deploy
USER node
WORKDIR /home/node/src
COPY --from=build --chown=node:node /build .
CMD ["node", "index.js"]
ENV NODE_ENV production
CMD ["yarn", "start"]
+28 -30
View File
@@ -3,50 +3,48 @@ version: '3.1'
services:
api:
build: .
container_name: radio-rolnik_api
image: radio-rolnik/api
restart: always
container_name: api
depends_on:
- mongo
- redis
links:
- mongo
- redis
environment:
HTTP_PORT: 3010
# WS_PORT: 3020
WS_PORT: 3020
DB_HOST: mongo
DB_PORT: 27017
DB_NAME: radio-rolnik
DB_USER: root
DB_PASS: supersecurepassword123
DB_NAME: api
DB_USER: radio-rolnikcred
DB_PASS: radio-rolnikcred
CACHE_HOST: redis
CACHE_PORT: 6379
ports:
- 3010:3010
- 3020:3020
depends_on:
- mongo
links:
- mongo
mongo:
image: mongo:5.0
container_name: mongo
container_name: radio-rolnik_mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: supersecurepassword123
volumes:
- ./database:/data/db
ports:
- 27017:27017
command: --quiet
- ./data/mongo:/data/db
command:
- '--logpath'
- '/var/log/mongodb/mongod.log'
environment:
MONGO_INITDB_ROOT_USERNAME: radio-rolnikcred
MONGO_INITDB_ROOT_PASSWORD: radio-rolnikcred
redis:
image: redis:6.2-alpine
container_name: redis
container_name: radio-rolnik_redis
restart: always
environment:
ALLOW_EMPTY_PASSWORD: 'yes'
ports:
- 6379:6379
nginx:
image: nginx:1.21-alpine
container_name: nginx
restart: always
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- 80:80
-28
View File
@@ -1,28 +0,0 @@
server {
listen 80;
location / {
proxy_pass http://host.docker.internal:3000/;
}
location /api/ {
proxy_pass http://api:3010/;
}
location /ws/ {
proxy_pass http://api:3020/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy false;
proxy_read_timeout 86400s;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}