Skip to content

Commit acd6ea8

Browse files
authored
fix: update docker
1 parent 908f2da commit acd6ea8

File tree

3 files changed

+39
-26
lines changed

3 files changed

+39
-26
lines changed

.dockerignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ node_modules
44
npm-debug.log
55
README.md
66
.git
7-
.env
7+
.env
8+
dist
9+
docker-compose.yaml

Dockerfile

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1-
FROM node:18-alpine
2-
WORKDIR /
1+
FROM node:18-slim AS base
2+
ENV PNPM_HOME="/pnpm"
3+
ENV PATH="$PNPM_HOME:$PATH"
4+
#Hook into pnpm without installing pnpm. (magic) (https://nodejs.org/docs/latest-v18.x/api/corepack.html)
5+
RUN corepack enable
6+
WORKDIR /usr/src/app
7+
COPY package*.json pnpm-lock*.yaml ./
38

4-
COPY package*.json pnpm-lock.yaml* ./
5-
RUN npm i -g pnpm
69

7-
RUN pnpm install
10+
#Create node_modules files without dev dependencies.
11+
FROM base AS prod_dependencies
12+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
813

14+
#Create dist.
15+
FROM base AS builder
916
COPY . .
10-
17+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
1118
RUN pnpm run build
1219

13-
CMD pnpm run start
20+
#Final image
21+
FROM base
22+
ENV NODE_ENV production
23+
WORKDIR /usr/src/app
24+
COPY --from=prod_dependencies /usr/src/app/node_modules ./node_modules
25+
COPY --from=builder /usr/src/app/dist ./dist
26+
CMD [ "pnpm", "run", "start" ]

docker-compose.yaml

+16-18
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
version: "3.3"
2-
1+
version: "3.9"
32
services:
4-
website:
5-
container_name: "bot"
6-
image: dominikdoesdev/wy-bot
7-
environment:
8-
- TZ=Europe/Berlin
9-
- TEST_GUILD_ID=
10-
- STATUS=DEVELOPMENT
11-
- BOTSTATUS=Would You?
12-
- TOKEN=
13-
- ENCRYPTION_KEY=
14-
- TOPGG_TOKEN=
15-
- TOPGG_WEBHOOK=
16-
- SENTRY_DSN=
17-
- MONGO_URI=
18-
- LOG_PRIVATE=
19-
- LOG_GUILDS=
3+
wouldyou-bot:
4+
container_name: bot
5+
build:
6+
context: .
7+
dockerfile: dockerfile
8+
restart: unless-stopped
9+
env_file:
10+
- .env
11+
networks:
12+
- node
13+
labels:
14+
gg.wouldyou.compose-author: "Discord username 536b656c6c79 "
15+
networks:
16+
node:
17+
driver: bridge

0 commit comments

Comments
 (0)