mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 02:09:07 +03:00
feat: nginx container
This commit is contained in:
parent
79e56696fd
commit
416f221066
@ -1,12 +1,12 @@
|
||||
# Adonis default .gitignore ignores
|
||||
node_modules
|
||||
build
|
||||
uploads
|
||||
coverage
|
||||
.vscode
|
||||
.DS_STORE
|
||||
.env
|
||||
tmp
|
||||
uploads
|
||||
|
||||
# Additional .gitignore ignores (any custom file you wish)
|
||||
.idea
|
||||
|
||||
24
Dockerfile
24
Dockerfile
@ -1,30 +1,24 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
ARG NODE_IMAGE=node:14.17.3-alpine3.11
|
||||
|
||||
ARG NODE_IMAGE=node:17-alpine
|
||||
|
||||
FROM ${NODE_IMAGE} as base
|
||||
FROM ${NODE_IMAGE} AS base
|
||||
RUN apk --no-cache add dumb-init
|
||||
RUN mkdir -p /home/node/app && chown node:node /home/node/app
|
||||
WORKDIR /home/node/app
|
||||
USER node
|
||||
RUN mkdir tmp
|
||||
|
||||
FROM base as dependencies
|
||||
COPY --chown=node:none ./package*.json ./
|
||||
FROM base as builder
|
||||
COPY --chown=node:node package*.json ./
|
||||
RUN npm ci
|
||||
COPY --chown=node:node . .
|
||||
|
||||
FROM dependencies as build
|
||||
RUN node ace build --production --ignore-ts-errors
|
||||
RUN node ace build --production
|
||||
|
||||
FROM base as production
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3333
|
||||
ENV HOST=0.0.0.0
|
||||
|
||||
COPY --chown=node:node ./package*.json ./
|
||||
WORKDIR /home/node/app
|
||||
COPY --chown=node:node --from=builder /home/node/app/build .
|
||||
RUN npm ci --production
|
||||
COPY --chown=node:node --from=build /home/node/app/build .
|
||||
|
||||
EXPOSE 3333
|
||||
CMD [ "dumb-init", "node", "server.js" ]
|
||||
CMD ["dumb-init", "node", "server.js"]
|
||||
14
Makefile
Normal file
14
Makefile
Normal file
@ -0,0 +1,14 @@
|
||||
build:
|
||||
docker-compose -f docker-compose.yml build $(c)
|
||||
up:
|
||||
docker-compose -f docker-compose.yml up -d $(c)
|
||||
down:
|
||||
docker-compose -f docker-compose.yml down $(c)
|
||||
stop:
|
||||
docker-compose -f docker-compose.yml stop $(c)
|
||||
logs:
|
||||
docker-compose -f docker-compose.yml logs --tail=100 -f $(c)
|
||||
migrate:
|
||||
docker-compose -f docker-compose.yml run nodejs npm run db:migrate:force
|
||||
seed:
|
||||
docker-compose -f docker-compose.yml run nodejs npm run db:seed
|
||||
@ -17,9 +17,10 @@ export default class OnlineController {
|
||||
this.socket = socket;
|
||||
this.io = io;
|
||||
this.sessionStore = sessionStore;
|
||||
}
|
||||
|
||||
this.onConnected(socket);
|
||||
|
||||
public handle() {
|
||||
this.onConnected(this.socket);
|
||||
this.socket.on('disconnect', reason => this.onDisconnected(reason));
|
||||
}
|
||||
|
||||
|
||||
@ -115,9 +115,10 @@ class WsService {
|
||||
|
||||
private listen() {
|
||||
this.io.on('connection', async socket => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const onlineController = new OnlineController(socket, this.io, this.sessionStore);
|
||||
|
||||
onlineController.handle();
|
||||
|
||||
const { sessionId, userId, userName } = socket.data;
|
||||
const isExistSocketData = !!(sessionId && userId && userName);
|
||||
|
||||
|
||||
@ -1,37 +1,72 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
backend:
|
||||
container_name: educt-server
|
||||
nginx:
|
||||
container_name: nginx
|
||||
restart: always
|
||||
image: nginx:latest
|
||||
volumes:
|
||||
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
|
||||
ports:
|
||||
- 80:80
|
||||
depends_on:
|
||||
- api
|
||||
networks:
|
||||
- app-network
|
||||
api:
|
||||
container_name: api
|
||||
restart: always
|
||||
build:
|
||||
context: .
|
||||
target: dependencies
|
||||
target: production
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- ${PORT}:${PORT}
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- PORT=3333
|
||||
- APP_KEY=IP387l45rlNO3t7Qgjd89qr-a2G4oUgz
|
||||
- DB_CONNECTION=pg
|
||||
- PG_HOST=postgres
|
||||
- PG_PORT=5432
|
||||
- PG_USER=postgres
|
||||
- PG_PASSWORD=1234
|
||||
- PG_DB_NAME=educt
|
||||
- REDIS_CONNECTION=local
|
||||
- REDIS_HOST=redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=
|
||||
- SMTP_HOST=localhost
|
||||
- SMTP_PORT=587
|
||||
- SMTP_USERNAME=<username>
|
||||
- SMTP_PASSWORD=<password>
|
||||
- MAILGUN_API_KEY=<key>
|
||||
- MAILGUN_DOMAIN=<domain>
|
||||
- CACHE_VIEWS=false
|
||||
- DRIVE_DISK=local
|
||||
- S3_KEY=<key>
|
||||
- S3_SECRET=<secret>
|
||||
- S3_BUCKET=<bucket>
|
||||
- S3_REGION=<region>
|
||||
volumes:
|
||||
- ./:/home/node/app
|
||||
command: dumb-init node ace serve --watch
|
||||
- uploads:/home/node/app/uploads
|
||||
command: ['dumb-init', 'node', 'server.js']
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
networks:
|
||||
- app-network
|
||||
postgres:
|
||||
container_name: postgres
|
||||
image: postgres:14
|
||||
volumes:
|
||||
- postgres_volume:/var/lib/postgresql/data
|
||||
environment:
|
||||
POSTGRES_USER: ${PG_USER}
|
||||
POSTGRES_PASSWORD: ${PG_PASSWORD}
|
||||
POSTGRES_DB: ${PG_DB_NAME}
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: 1234
|
||||
POSTGRES_DB: educt
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
networks:
|
||||
- app-network
|
||||
redis:
|
||||
container_name: redis
|
||||
image: redis:6-alpine
|
||||
@ -39,6 +74,14 @@ services:
|
||||
- redis_volume:/data
|
||||
ports:
|
||||
- 6379:6379
|
||||
networks:
|
||||
- app-network
|
||||
depends_on:
|
||||
- postgres
|
||||
volumes:
|
||||
postgres_volume:
|
||||
redis_volume:
|
||||
uploads:
|
||||
networks:
|
||||
app-network:
|
||||
driver: bridge
|
||||
|
||||
17
nginx/default.conf
Normal file
17
nginx/default.conf
Normal file
@ -0,0 +1,17 @@
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
proxy_pass http://api:3333;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
}
|
||||
11381
package-lock.json
generated
11381
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -32,6 +32,7 @@
|
||||
"youch-terminal": "^1.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@adonisjs/application": "^5.2.0",
|
||||
"@adonisjs/attachment-lite": "^1.0.1",
|
||||
"@adonisjs/auth": "^8.0.10",
|
||||
"@adonisjs/bouncer": "^2.2.5",
|
||||
@ -48,6 +49,7 @@
|
||||
"luxon": "^1.28.0",
|
||||
"nanoid": "^3.1.25",
|
||||
"pg": "^8.7.1",
|
||||
"phc-bcrypt": "^1.0.7",
|
||||
"proxy-addr": "^2.0.7",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"socket.io": "^4.4.1",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user