52 lines
1.1 KiB
Docker
52 lines
1.1 KiB
Docker
FROM oven/bun:alpine AS base
|
|
WORKDIR /usr/src/app
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
ENV APP_USER_DATA_PATH="/app-data/user-data"
|
|
ENV APP_TMP_USER_DATA_PATH="/app-data/tmp"
|
|
|
|
## Stage 1: Install dependencies
|
|
FROM base AS install
|
|
|
|
# install development dependencies
|
|
RUN mkdir -p /temp/dev
|
|
COPY package.json bun.lockb /temp/dev/
|
|
RUN cd /temp/dev && bun install --frozen-lockfile
|
|
|
|
# install production dependencies
|
|
RUN mkdir -p /temp/prod
|
|
COPY package.json bun.lockb /temp/prod/
|
|
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
|
|
|
## Stage 2: Build app
|
|
FROM base AS prerelease
|
|
|
|
# copy dependencies into workdir
|
|
COPY --from=install /temp/dev/node_modules node_modules
|
|
|
|
# add project files
|
|
COPY . .
|
|
|
|
# build project
|
|
RUN bun run build
|
|
|
|
## Stage 3: Put everything together
|
|
FROM base AS release
|
|
|
|
# compose the final image
|
|
COPY --from=install /temp/prod/node_modules node_modules
|
|
COPY --from=prerelease /usr/src/app/build .
|
|
COPY --from=prerelease /usr/src/app/templates .
|
|
#COPY --from=prerelease /usr/src/app/package.json .
|
|
|
|
RUN mkdir /app-data && chown bun:bun /app-data
|
|
|
|
VOLUME ["/app-data"]
|
|
|
|
USER bun
|
|
EXPOSE 3000/tcp
|
|
ENTRYPOINT [ "bun", "--bun", "./index.js" ]
|
|
#CMD [ "ls -al" ]
|
|
|