Skip to content

Commit

Permalink
add dockerfile for remix and update docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
sitek94 committed Nov 25, 2023
1 parent 2e19ff4 commit b6ff73c
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 8 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
- [x] move linters and shared packages to root
- [x] extend `tsconfig.json` from root based on app
- [x] create simple Dockerfile for NestJS
- Pnpm docs: https://pnpm.io/docker
- use pnpm deploy
- make sure to copy from root tsconfig package.json etc
- [ ] create simple Dockerfile for Remix
- [ ] update docker compose
- [x] create simple Dockerfile for Remix
- [x] update docker compose
- [x] create CI workflow (lint + build only)
- [ ] add simple tests to CI workflow
- [ ] create CI deployment workflow (Fly.io?)
Expand Down
9 changes: 7 additions & 2 deletions apps/nestjs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ RUN pnpm deploy --filter=nestjs --prod /prod/nestjs
# Stage 3: Production
# Copy the built app and run it
FROM node:20-alpine AS production
COPY --from=build /prod/nestjs/node_modules /prod/nestjs/node_modules
COPY --from=build /prod/nestjs/build /prod/nestjs/build

ENV NODE_ENV=production
ENV PORT=2222

WORKDIR /prod/nestjs

COPY --from=build /prod/nestjs/node_modules ./node_modules
COPY --from=build /prod/nestjs/build ./build


USER node

CMD [ "node", "build/main.js" ]
Expand Down
34 changes: 34 additions & 0 deletions apps/remix/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Stage 1: Base
# Set up base Node.js environment and enable pnpm
FROM node:20-alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

# Stage 2: Build
# Install dependencies and build the app
FROM base AS build
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm build:remix
RUN pnpm deploy --filter=remix --prod /prod/remix

# Stage 3: Production
# Copy the built app and run it
FROM node:20-alpine AS production

ENV NODE_ENV=production
ENV PORT=3333

WORKDIR /prod/remix

COPY --from=build /prod/remix/node_modules ./node_modules
COPY --from=build /prod/remix/build ./build
COPY --from=build /prod/remix/public ./public
COPY --from=build /prod/remix/package.json ./package.json

USER node

CMD [ "npm", "run", "start" ]

17 changes: 16 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
services:
remix:
container_name: remix
build:
context: .
dockerfile: ./apps/remix/Dockerfile
ports:
- 3333:3333
environment:
API_URL: http://nestjs:2222
depends_on:
- nestjs
networks:
- app-network

nestjs:
container_name: nestjs
build:
context: .
dockerfile: ./apps/nestjs/Dockerfile
Expand All @@ -13,8 +28,8 @@ services:
- app-network

mongo:
container_name: mongo
image: mongo:latest
container_name: mongodb
restart: always
ports:
- 27017:27017
Expand Down

0 comments on commit b6ff73c

Please sign in to comment.