Skip to content

Commit

Permalink
chore: docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
minextu committed Nov 23, 2024
1 parent e0d3061 commit 69fcf81
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
.git
.gitignore
*.md
dist
Dockerfile
6 changes: 4 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Extract these from the game exectuable
# log output will be in color even inside docker, if set to 1
FORCE_COLOR=1
# Extract these next 2 secrets from the game exectuable
MASTER_SECRET=
# 9 strings comma seperated
# 9 strings comma seperated, i.e. GAME_SECRETS=abc,def,ghi,jkl,mno,pqr,stu,wxy,zab
GAME_SECRETS=
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM node:22-alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

RUN corepack enable

USER node
WORKDIR /app

# Dependencies
FROM base AS prod-deps
COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

# Building
FROM base AS build
COPY . .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

# Run
FROM base as runner
ENV NODE_ENV production

COPY --chown=node:node --from=build /app/dist /app/dist
COPY --chown=node:node --from=prod-deps /app/package.json /app/package.json
COPY --chown=node:node --from=prod-deps /app/node_modules /app/node_modules

RUN corepack pack

CMD ["pnpm", "start"]
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
server:
build: .
env_file: ".env"
ports:
- "80:80"
- "8085:8085/udp"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"scripts": {
"dev": "tsx watch src/index.ts",
"start": "node dist/index.js",
"start": "node dist/src/index.js",
"build": "tsc",
"type-check": "tsc --noEmit",
"lint": "eslint .",
Expand Down

0 comments on commit 69fcf81

Please sign in to comment.