Finally make the Docker build work

This commit is contained in:
Jesse Wierzbinski 2024-04-06 20:13:09 -10:00
parent b580d1a24a
commit e88c5f3fd0
No known key found for this signature in database
5 changed files with 251 additions and 198 deletions

View file

@ -1,37 +1,39 @@
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1.0.30-alpine as base
WORKDIR /usr/src/app
# Use the official Bun image (Bun doesn't run well on Musl but this seems to work)
# See all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1.1.2-alpine as base
# Install dependencies into temp directory
# This will cache them and speed up future builds
FROM base AS install
# Install with --production (exclude devDependencies)
RUN mkdir -p /temp
COPY . /temp
WORKDIR /temp
RUN bun install --frozen-lockfile
FROM base as build
# 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
# install with --production (exclude devDependencies)
# Copy the project
RUN mkdir -p /temp
COPY . /temp
WORKDIR /temp
RUN bun install --frozen-lockfile --production
# Build Vite in pages
RUN bunx --bun vite build pages
# Copy dependencies
COPY --from=install /temp/node_modules /temp/node_modules
# Build the project
RUN bun run build.ts
WORKDIR /temp/dist
WORKDIR /temp
RUN bun run prod-build
# copy production dependencies and source code into final image
FROM base AS release
# Create app directory
RUN mkdir -p /app
COPY --from=install /temp/dist /app/dist
COPY --from=build /temp/dist /app/dist
COPY entrypoint.sh /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"