Skip to content

Commit

Permalink
fix: ajust docker compose and dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
PiluVitu committed Aug 26, 2024
1 parent 1cd5406 commit 1242e10
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
28 changes: 21 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
FROM node:22 AS build
FROM node:22 AS base

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

WORKDIR /usr/src/app

RUN npm install -g pnpm@8
RUN corepack enable && corepack prepare pnpm@8.6.0 --activate

COPY ./package.json ./pnpm-lock.yaml ./

COPY ./ .

RUN pnpm install --frozen-lockfile -r
FROM base AS prod-deps

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile

FROM base AS build

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN npx prisma generate
RUN pnpm build

FROM node:22-alpine3.19

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"


RUN corepack enable && corepack prepare pnpm@8.6.0 --activate


WORKDIR /usr/src/app
RUN npm install -g pnpm@8
COPY --from=build /usr/src/app/package.json ./package.json
COPY --from=build /usr/src/app/build ./build
COPY --from=build /usr/src/app/node_modules ./node_modules
COPY --from=prod-deps /usr/src/app/node_modules ./node_modules

EXPOSE 3000

CMD ["pnpm", "run", "start"]
CMD ["pnpm", "start"]
26 changes: 15 additions & 11 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
services:
db-dev: &db
container_name: octopost-db-dev
profiles:
- dev
image: mongo:7.0.14-rc0-nanoserver-ltsc2022
image: mongo:7.0.14-rc0-jammy
ports:
- '27017:27017'
environment:
Expand All @@ -14,19 +13,17 @@ services:
networks:
- octopost

mongo-express:
mongo-express-dev: &mg-express
profiles:
- dev
image: mongo-express
restart: always
depends_on: [db-dev]
ports:
- 3476:8081
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: $MONGODB_ADMINUSERNAME
ME_CONFIG_MONGODB_ADMINPASSWORD: $MONGODB_ADMINPASSWORD
ME_CONFIG_MONGODB_URL: $MONGODB_URL
ME_CONFIG_MONGODB_URL: 'mongodb://octopost:1234@db-dev:27017'
ME_CONFIG_BASICAUTH: false
links:
- db-dev
networks:
- octopost

Expand All @@ -38,15 +35,22 @@ services:
profiles:
- prod
ports:
- 3000:3000
- '${PORT}:${PORT}'
depends_on:
- db-prod
networks:
- octopost

mongo-express-prod:
<<: *mg-express
profiles:
- prod
environment:
ME_CONFIG_BASICAUTH: false
ME_CONFIG_MONGODB_URL: 'mongodb://octopost:1234@db-prod:27017'

db-prod:
<<: *db
container_name: octopost-db
profiles:
- prod

Expand Down

0 comments on commit 1242e10

Please sign in to comment.