Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ VITE_IS_DEMO="false"
# DATABASE
DATABASE_URL="postgres://${DOCKER_DATABASE_USERNAME}:${DOCKER_DATABASE_PASSWORD}@localhost:${DOCKER_DATABASE_PORT}/${DOCKER_DATABASE_NAME}"

# for docker build use:
# DATABASE_URL="postgres://${DOCKER_DATABASE_USERNAME}:${DOCKER_DATABASE_PASSWORD}start-ui-web-postgres-1/${DOCKER_DATABASE_NAME}"

# AUTH
AUTH_SECRET="REPLACE ME" # You can use `npx @better-auth/cli@latest secret` to a generated secret
AUTH_SESSION_EXPIRATION_IN_SECONDS=2592000 # 30 days
Expand Down
59 changes: 59 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Stage 1: builder
FROM node:22-alpine AS builder

WORKDIR /app

# install pnpm & git
RUN npm install -g pnpm
RUN apk update && \
apk upgrade && \
apk add --no-cache git

RUN git init


# copy lock, package files and configs
COPY package.json pnpm-lock.yaml ./
COPY run-jiti.js ./
COPY src/features/build-info/script-to-generate-json.ts src/features/build-info/build-info.gen.json ./src/features/build-info/
COPY prisma/schema.prisma ./prisma/

RUN pnpm install --frozen-lockfile

# copy source
COPY . .

ENV NODE_OPTIONS=--max-old-space-size=4096

# build app
RUN pnpm build


# Stage 2: runtime
FROM node:22-alpine AS runtime


WORKDIR /app

# ENV
ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=3000

# install pnpm
RUN npm install -g pnpm npm-run-all
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is npm-run-all needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run-p not found if I don't install npm run all


COPY .env ./



## copy output build and package.json from builder
COPY --from=builder /app/.output ./.output
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/node_modules ./node_modules

EXPOSE 3000

# start
CMD ["pnpm", "start"]
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"dk:start": "docker compose start",
"dk:stop": "docker compose stop",
"dk:clear": "docker compose down --volumes",
"dk:build": "docker build -t start-ui-web . && docker run -d --network start-ui-web_default -p 3000:3000 --name start-ui-web-container start-ui-web",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to build a Docker image to deploy on some Docker running platform like k8s, we don't really want a script in package.json but more of a command to copy/paste in the README (just the docker build -t start-ui-web . part I think, and then how to use this built docker image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tell me if in the readme.md section Dockerfile, the description and command match with your suggestion

"db:init": "pnpm db:push && pnpm db:seed",
"db:push": "prisma db push",
"db:ui": "prisma studio",
Expand Down
Loading