mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-02 00:50:57 +01:00
chore: include initial Dockerfile
This commit is contained in:
parent
1de3caf215
commit
bc42f14ae1
1 changed files with 36 additions and 0 deletions
36
Dockerfile
Normal file
36
Dockerfile
Normal file
|
@ -0,0 +1,36 @@
|
|||
FROM oven/bun:latest AS base
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Temporarily install dependencies to a new layer
|
||||
FROM base AS install
|
||||
RUN mkdir -p /temp/dev
|
||||
COPY package.json bun.lockb /temp/dev/
|
||||
RUN cd /temp/dev && bun install --frozen-lockfile
|
||||
|
||||
# Install non-dev dependencies
|
||||
RUN mkdir -p /temp/prod
|
||||
COPY package.json bun.lockb /temp/prod/
|
||||
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
||||
|
||||
# Prepare for build by copying source and dependencies from install layer
|
||||
FROM base AS build
|
||||
COPY --from=install /temp/dev/node_modules node_modules
|
||||
COPY . .
|
||||
|
||||
# Also install other dependencies for the build script
|
||||
RUN apt-get update && apt-get install git -y
|
||||
|
||||
# Build the worker
|
||||
ENV NODE_ENV=production
|
||||
RUN bun run build
|
||||
|
||||
# copy production dependencies and source code into final image
|
||||
FROM base AS release
|
||||
COPY --from=install /temp/prod/node_modules node_modules
|
||||
COPY --from=build /usr/src/app/dist dist
|
||||
COPY --from=build /usr/src/app/package.json .
|
||||
|
||||
# Run as non-priveleged user
|
||||
USER bun
|
||||
EXPOSE 3000/tcp
|
||||
ENTRYPOINT [ "bun", "run", "dist/worker.js" ]
|
Loading…
Add table
Reference in a new issue