Skip to content
Draft
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
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.git
.gitignore
*.md
packages/client/dist
64 changes: 64 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# syntax=docker/dockerfile:1

# Build Arguments
ARG NODE_VERSION="24"
ARG DEBIAN_VERSION="trixie"
ARG NGINX_VERSION="1.29"
ARG ALPINE_VERSION="3.22"

# Build Stage
FROM --platform=${BUILDPLATFORM} docker.io/node:${NODE_VERSION}-${DEBIAN_VERSION}-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

FROM base AS builder
WORKDIR /usr/src/app
COPY . .
COPY packages/client/.env.example packages/client/.env

FROM builder AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

FROM builder AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm build:deps # TODO: Combine with previous
RUN pnpm build:web

FROM builder AS build-prod
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm build:deps # TODO: Combine with previous
RUN pnpm build:prod

# Dev Stage
FROM base AS dev
COPY --chown=nonroot:nonroot package.json pnpm-lock.yaml ./
COPY --chown=nonroot:nonroot --from=prod-deps /usr/src/app/node_modules node_modules
COPY --chown=nonroot:nonroot --from=build /usr/src/app/packages/client packages/client

# Entrypoint
#USER nonroot
#COPY --chown=nonroot:nonroot --chmod=755 scripts/entrypoint.sh /tmp
#RUN ls -al /tmp && ls -al
VOLUME [ "/data" ]
EXPOSE 5173
#ENTRYPOINT ["/tmp/entrypoint.sh"]
CMD [ "pnpm", "dev:web" ]

# Prod Stage
#FROM base AS prod
#RUN adduser --disabled-password --no-create-home --shell=/bin/false nonroot
#RUN groupadd -g 1001 nonroot && \
# useradd -u 1001 -g nonroot -m -d /usr/src/app -s /bin/false nonroot
#WORKDIR /usr/src/app

# Entrypoint
#RUN ls -al /tmp && ls -al
#VOLUME [ "/data" ]
#EXPOSE 8080
#CMD [ "pnpm", "start:web" ]
# NGINX

FROM docker.io/nginxinc/nginx-unprivileged:${NGINX_VERSION}-alpine${ALPINE_VERSION}-slim AS prod
COPY --from=build-prod /usr/src/app/packages/client/dist /usr/share/nginx/html
COPY conf/nginx.conf /etc/nginx/conf.d/default.conf
42 changes: 42 additions & 0 deletions conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
server {
listen 8080;
listen [::]:8080;
server_name default;

root /usr/share/nginx/html;
index index.html;

include /etc/nginx/mime.types;

# types {
# application/javascript mjs js;
# }

gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;

# Assets - ONE simple block for all static files
location /assets/ {
root /usr/share/nginx/html;
autoindex off;

add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;

try_files $uri =404;
}

# Handle all other routes
location / {
try_files $uri $uri/ /index.html;
add_header Cache-Control "no-cache";
}

server_tokens off;
}
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"setup:assets": "node scripts/copyAssets.mjs",
"dev": "npm run setup:assets && vite --host",
"build": "npm run setup:assets && vite build",
"build:prod": "npm run setup:assets && BASE_PATH=/app/ vite build",
"build:prod": "npm run setup:assets && BASE_PATH=/ vite build",
"serve": "vite preview",
"test:typecheck": "tsc --noEmit",
"test:suite": "vitest",
Expand Down
5 changes: 5 additions & 0 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
# Fail fast!
set -e

exec "$@"