Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.dockerignore
.git
.github
.gitignore
.vscode
dist
docker-compose*
Dockerfile*
node_modules
DB
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# syntax=docker/dockerfile:1

# Build stage
FROM node:lts-alpine AS build

WORKDIR /app

COPY --chown=node:node package*.json ./

RUN npm ci

COPY --chown=node:node . .

RUN npm run build

USER node

# Production stage
FROM node:lts-alpine

ARG PORT
ENV PORT=${PORT}
ARG NODE_ENV
ENV NODE_ENV=${NODE_ENV}

WORKDIR /app

COPY --chown=node:node package*.json ./

RUN npm ci --omit=dev

COPY --chown=node:node --from=build /app/src/config ./config
COPY --chown=node:node --from=build /app/dist ./dist

CMD node dist/main.js
2 changes: 1 addition & 1 deletion docker-compose.yml → docker-compose.db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.8'

services:
mariadb:
container_name: MariaDB
container_name: mariadb
image: mariadb
ports:
- 3306:3306
Expand Down
21 changes: 21 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.8'

services:
dongchelin:
container_name: dongchelin
depends_on:
- redis
- mariadb
build:
context: .
# dockerfile: Dockerfile
args:
- NODE_ENV=development
env_file:
- src/config/.env.development
volumes:
- ./dist:/app/dist
environment:
- PORT=3002
ports:
- 3002:3002