Skip to content

Commit a6f23cd

Browse files
committed
Feat: Docker compose 수정
1 parent 6342146 commit a6f23cd

File tree

4 files changed

+46
-10
lines changed

4 files changed

+46
-10
lines changed

.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Ignore all files in the node_modules directory
2+
node_modules/
3+
4+
# Ignore the .git directory and all files in it
5+
.git/
6+
7+
# Ignore all files in the dist directory
8+
dist/
9+
10+
# Ignore all files with the .log or .md extension
11+
*.log
12+
*.md

Dockerfile

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1-
FROM node:18-alpine
1+
FROM node:20-alpine AS builder
22

3-
RUN npm install -g npm@9.8.1
4-
RUN npm i -g pnpm
53
WORKDIR /app
4+
RUN npm i -g pnpm
5+
6+
COPY package.json ./
7+
COPY pnpm-lock.yaml ./
8+
9+
RUN pnpm install
10+
RUN pnpm add express
11+
12+
COPY . .
13+
COPY .production.env ./
614

7-
COPY ./package.json /app
8-
COPY ./pnpm-lock.yaml /app
9-
RUN pnpm i --frozen-lockfile
1015

11-
#TODO: add db migrate command
16+
RUN pnpm run build
17+
18+
FROM node:20-alpine AS runner
19+
20+
WORKDIR /app
21+
COPY --from=builder --chown=node:node /app/dist ./dist
22+
COPY --from=builder --chown=node:node /app/node_modules ./node_modules
23+
COPY --from=builder --chown=node:node /app/.production.env ./.production.env
24+
25+
ENV NODE_ENV=production
26+
USER node
1227

13-
COPY . /app
14-
RUN pnpm run build
28+
CMD ["node", "dist/main.js"]

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
services:
2+
app:
3+
container_name: korrk_backend
4+
restart: always
5+
build: .
6+
ports:
7+
- '${PORT}:${PORT}'
8+
depends_on:
9+
postgres:
10+
condition: service_healthy
11+
212
postgres:
313
image: postgres
414
container_name: postgres

src/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { UtilModule } from './util/util.module';
2525
envFilePath: `${__dirname}/../.${getNodeEnv}.env`,
2626
cache: true,
2727
validate: envValidation,
28-
ignoreEnvFile: isIgnoreEnvFile,
28+
// ignoreEnvFile: isIgnoreEnvFile,
2929
}),
3030
MikroOrmModule.forRoot(),
3131
AuthModule,

0 commit comments

Comments
 (0)