Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
94 changes: 94 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Builder Stage
FROM node:22-alpine AS builder

WORKDIR /app

# install tools
RUN npm install -g pnpm && \
apk add --no-cache git && \
git init

# copy files needed for installing dependencies
COPY package.json pnpm-lock.yaml ./
COPY prisma/schema.prisma ./prisma/
COPY run-jiti.js ./
COPY src/features/build-info/script-to-generate-json.ts ./src/features/build-info/

# install dependencies
RUN pnpm install --frozen-lockfile

ARG VITE_BASE_URL
ARG VITE_ENV_NAME
ARG VITE_ENV_EMOJI
ARG VITE_ENV_COLOR
ARG VITE_IS_DEMO
ARG DATABASE_URL
ARG AUTH_SECRET
ARG GITHUB_CLIENT_ID
ARG GITHUB_CLIENT_SECRET
ARG EMAIL_SERVER
ARG EMAIL_FROM

ENV VITE_BASE_URL=${VITE_BASE_URL} \
VITE_ENV_NAME=${VITE_ENV_NAME} \
VITE_ENV_EMOJI=${VITE_ENV_EMOJI} \
VITE_ENV_COLOR=${VITE_ENV_COLOR} \
VITE_IS_DEMO=${VITE_IS_DEMO} \
DATABASE_URL=${DATABASE_URL} \
AUTH_SECRET=${AUTH_SECRET} \
GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID} \
GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET} \
EMAIL_SERVER=${EMAIL_SERVER} \
EMAIL_FROM=${EMAIL_FROM}

# copy source code
COPY . .

# build the application
ENV NODE_OPTIONS=--max-old-space-size=4096
RUN pnpm build


# Runtime Stage
FROM node:22-alpine

WORKDIR /app

# install pnpm
RUN npm install -g pnpm npm-run-all


ARG VITE_BASE_URL
ARG VITE_ENV_NAME
ARG VITE_ENV_EMOJI
ARG VITE_ENV_COLOR
ARG VITE_IS_DEMO
ARG DATABASE_URL
ARG AUTH_SECRET
ARG GITHUB_CLIENT_ID
ARG GITHUB_CLIENT_SECRET
ARG EMAIL_SERVER
ARG EMAIL_FROM

ENV VITE_BASE_URL=${VITE_BASE_URL} \
VITE_ENV_NAME=${VITE_ENV_NAME} \
VITE_ENV_EMOJI=${VITE_ENV_EMOJI} \
VITE_ENV_COLOR=${VITE_ENV_COLOR} \
VITE_IS_DEMO=${VITE_IS_DEMO} \
DATABASE_URL=${DATABASE_URL} \
AUTH_SECRET=${AUTH_SECRET} \
GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID} \
GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET} \
EMAIL_SERVER=${EMAIL_SERVER} \
EMAIL_FROM=${EMAIL_FROM}

## 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 the application
CMD ["pnpm", "start"]
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,34 @@ pnpm dev
>
> Setup a PostgreSQL database (locally or online) and replace the **DATABASE_URL** environment variable. Then you can run `pnpm db:push` to update your database schema and then run `pnpm db:seed` to seed your database.

## Dockerfile

Build the image using the following command

```bash
docker build -t start-ui-web \
--build-arg VITE_BASE_URL="http://localhost:3000" \
--build-arg VITE_ENV_NAME="DOCKER" \
--build-arg VITE_ENV_EMOJI="🐋" \
--build-arg VITE_ENV_COLOR="blue" \
--build-arg VITE_IS_DEMO="true" \
--build-arg DATABASE_URL="postgres://user:pass@host:5432/db" \
--build-arg AUTH_SECRET="change-me" \
--build-arg GITHUB_CLIENT_ID="" \
--build-arg GITHUB_CLIENT_SECRET="" \
--build-arg EMAIL_SERVER="smtp://user:[email protected]:1025" \
--build-arg EMAIL_FROM="Start UI <[email protected]>" \
.
```
Then, you can run it with this example command:
```bash
docker run -d --network start-ui-web_default -p 3000:3000 --name start-ui-web-container start-ui-web
```

> [!NOTE]
> The network name `start-ui-web_default` is created by Docker Compose when you run `pnpm dk:start`. If you're running Docker without Docker Compose, use `--network bridge` or omit the `--network` flag.

During the build process, it automatically uses your project’s .env file.


### Emails in development
Expand Down
Loading