diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..344b3da --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.git +node_modules +data +build + +.vscode +.github + +DockerFile +.dockerignore +.prettierrc +.gitignore \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1519943..401805e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] \ No newline at end of file +ENV NODE_ENV production +CMD ["yarn", "start"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 1da6a6f..12d35df 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/nginx.conf b/nginx.conf deleted file mode 100644 index f8b4b41..0000000 --- a/nginx.conf +++ /dev/null @@ -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"; - } - -} \ No newline at end of file