Skip to content

Commit

Permalink
Add docker & compose files
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaHydrae committed Sep 27, 2024
1 parent 24d539c commit 7c85353
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://docs.docker.com/build/concepts/context/#dockerignore-files
/compose.yml
/Dockerfile
/.editorconfig
/eslint.config.mjs
/.github
/.gitignore
/node_modules
/nodemon.json
/.prettierignore
/.prettierrc.yml
/.tool-versions
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Builder image
# =============

FROM node:22.9.0-alpine AS builder

WORKDIR /app

COPY package.json package-lock.json ./
RUN npm ci

COPY . .
RUN npm prune --production

# Production image
# ================

FROM node:22.9.0-alpine

ENV NODE_ENV=production \
PORT=3000

LABEL org.opencontainers.image.authors="[email protected]"

WORKDIR /app

RUN addgroup -S onechatroom && \
adduser -D -G onechatroom -H -s /usr/bin/nologin -S onechatroom && \
chown onechatroom:onechatroom /app

USER onechatroom:onechatroom

COPY --chown=onechatroom:onechatroom --from=builder /app /app

CMD ["node", "./bin/www"]

EXPOSE 3000
32 changes: 32 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: one-chat-room

services:
app:
build:
context: .
image: archidep/one-chat-room
depends_on:
- db
environment:
- DATABASE_URL=mongodb://db:27017/one-chat-room
- DEBUG=one-chat-room:*
init: true
networks:
- app
- db
ports:
- '${ONE_CHAT_ROOM_PORT:-3000}:3000'

db:
image: mongo:8.0.0
networks:
- db
volumes:
- db-data:/data/db

networks:
app:
db:

volumes:
db-data:

0 comments on commit 7c85353

Please sign in to comment.