mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Add working Dockerfile
This commit is contained in:
parent
8b442c241c
commit
2c82cffb58
8 changed files with 27 additions and 15 deletions
27
Dockerfile
27
Dockerfile
|
|
@ -1,8 +1,12 @@
|
|||
# use the official Bun image
|
||||
# see all versions at https://hub.docker.com/r/oven/bun/tags
|
||||
FROM oven/bun:1.0.13-alpine as base
|
||||
FROM oven/bun:1.0.14-alpine as base
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
RUN apk add vips-dev
|
||||
# Required for Prisma to work
|
||||
COPY --from=node:18-alpine /usr/local/bin/node /usr/local/bin/node
|
||||
|
||||
# install dependencies into temp directory
|
||||
# this will cache them and speed up future builds
|
||||
FROM base AS install
|
||||
|
|
@ -13,13 +17,7 @@ RUN cd /temp/dev && bun install --frozen-lockfile
|
|||
# install with --production (exclude devDependencies)
|
||||
RUN mkdir -p /temp/prod
|
||||
COPY package.json bun.lockb /temp/prod/
|
||||
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
||||
|
||||
# copy node_modules from temp directory
|
||||
# then copy all (non-ignored) project files into the image
|
||||
FROM install AS prerelease
|
||||
COPY --from=install /temp/dev/node_modules node_modules
|
||||
COPY . .
|
||||
RUN cd /temp/prod && bun install --frozen-lockfile --production.
|
||||
|
||||
# copy production dependencies and source code into final image
|
||||
FROM base AS release
|
||||
|
|
@ -27,9 +25,20 @@ FROM base AS release
|
|||
# Create app directory
|
||||
RUN mkdir -p /app
|
||||
COPY --from=install /temp/prod/node_modules /app/node_modules
|
||||
COPY --from=prerelease /usr/src/app /app
|
||||
COPY . /app
|
||||
|
||||
LABEL org.opencontainers.image.authors "Gaspard Wierzbinski (https://cpluspatch.dev)"
|
||||
LABEL org.opencontainers.image.source "https://github.com/lysand-org/lysand"
|
||||
LABEL org.opencontainers.image.vendor "Lysand Org"
|
||||
LABEL org.opencontainers.image.licenses "AGPL-3.0"
|
||||
LABEL org.opencontainers.image.title "Lysand Server"
|
||||
LABEL org.opencontainers.image.description "Lysand Server docker image"
|
||||
|
||||
# run the app
|
||||
USER bun
|
||||
RUN bunx prisma generate
|
||||
# Remove Node
|
||||
USER root
|
||||
RUN rm /usr/local/bin/node
|
||||
USER bun
|
||||
ENTRYPOINT [ "bun", "run", "index.ts" ]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue