preciazo/sepa/Dockerfile

61 lines
1.8 KiB
Text
Raw Normal View History

2024-09-14 15:48:45 +00:00
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1.1 as base
2024-09-16 14:11:58 +00:00
RUN apt-get update && apt-get install ca-certificates && rm -rf /var/lib/apt/lists/*
2024-09-14 15:48:45 +00:00
WORKDIR /usr/src/app
# install dependencies into temp directory
# this will cache them and speed up future builds
# FROM base AS install
# RUN mkdir -p /temp/dev
# COPY package.json bun.lockb /temp/dev/
# COPY sitio2/package.json /temp/dev/sitio2/
# RUN cd /temp/dev/sitio2 && bun install --frozen-lockfile
# # install with --production (exclude devDependencies)
# RUN mkdir -p /temp/prod
# COPY package.json bun.lockb /temp/prod/
# COPY sitio2/package.json /temp/prod/sitio2/
# RUN cd /temp/prod/sitio2 && bun install --frozen-lockfile --production
# copy node_modules from temp directory
2024-09-14 16:03:22 +00:00
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
# COPY --from=install /temp/dev/node_modules node_modules
COPY . .
COPY db/schema.ts sitio2/src/lib/server/db/schema.ts
RUN cd sitio2 && bun install --frozen-lockfile
2024-09-14 15:48:45 +00:00
2024-09-14 16:03:22 +00:00
ARG DATABASE_URL
2024-09-16 14:09:06 +00:00
ARG SENTRY_AUTH_TOKEN
2024-09-14 15:48:45 +00:00
2024-09-14 16:03:22 +00:00
# [optional] tests & build
ENV NODE_ENV=production
ENV DATABASE_URL=$DATABASE_URL
2024-09-16 14:09:06 +00:00
ENV SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
2024-09-14 15:48:45 +00:00
2024-09-14 16:03:22 +00:00
# RUN bun test
RUN cd sitio2 && env DATABASE_URL="postgres://user:password@host:5432/db-name" bun run build
2024-09-14 15:48:45 +00:00
# copy production dependencies and source code into final image
FROM base AS release
# COPY --from=prerelease /usr/src/app/node_modules node_modules
2024-09-14 16:03:22 +00:00
COPY --from=prerelease /usr/src/app/sitio2/build .
# COPY sitio2/build .
2024-09-14 15:48:45 +00:00
RUN bun install --frozen-lockfile
ARG DATABASE_URL
ARG PORT=3000
ENV DATABASE_URL=$DATABASE_URL
ENV PROTOCOL_HEADER=x-forwarded-proto
ENV HOST_HEADER=x-forwarded-host
ENV PORT=$PORT
# run the app
USER bun
EXPOSE $PORT/tcp
ENTRYPOINT [ "bun", "--bun", "run", "index.js" ]