This commit is contained in:
Morten Olsen
2024-01-11 09:03:14 +01:00
commit 36f63662ad
82 changed files with 7071 additions and 0 deletions

42
docker/Dockerfile Normal file
View File

@@ -0,0 +1,42 @@
FROM node:18-alpine AS base
RUN corepack enable
FROM base AS builder
RUN apk add --no-cache libc6-compat
RUN apk update
RUN npm install -g turbo
# Set working directory
WORKDIR /app
COPY . .
RUN turbo prune @morten-olsen/mini-loader-server --docker
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
RUN pnpm install
# Build the project
COPY --from=builder /app/out/full/ .
RUN pnpm turbo run build --filter=@morten-olsen/mini-loader-server
FROM base AS runner
WORKDIR /app
# Don't run production as root
RUN \
ln -s /app/packages/server/bin/index.mjs /usr/local/bin/mini-loader-server
COPY ./docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
COPY --from=installer /app .
EXPOSE 4500
ENTRYPOINT ["/entrypoint.sh"]
CMD ["mini-loader-server"]

12
docker/entrypoint.sh Normal file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
CMD=$@
UID=${UID:-1001}
GID=${GID:-1001}
addgroup --system --gid ${GID} nodejs && \
adduser --system --uid ${UID} -G nodejs miniloader && \
mkdir -p /app/data
chown -R miniloader:nodejs /app/data
su miniloader -s /bin/sh -c "$CMD"