Created
September 20, 2023 15:01
-
-
Save bjarneo/c2848dd6b335975f18cdddb8ad36de79 to your computer and use it in GitHub Desktop.
Dockerfile for bun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Let us create the build step | |
FROM oven/bun as builder | |
# Set the working directory | |
WORKDIR /bun-builder | |
# Copy package and bun lock file to the workdir | |
COPY package.json bun.lockb ./ | |
# Install dependencies | |
RUN bun install | |
# Copy our API http server | |
COPY http.ts ./ | |
# Build the project | |
RUN bun build --target=bun ./http.ts --outfile=http.js | |
# Let us create the run step | |
FROM oven/bun | |
# Set a new and fresh workdri | |
WORKDIR /bun-api | |
# Copy the relevant files we need from the builder | |
COPY --from=builder /bun-builder/http.js ./ | |
COPY --from=builder /bun-builder/package.json ./ | |
# Start the application | |
CMD [ "bun", "http.js" ] | |
# Notes: | |
# If you have production dependencies you have to install those in the last steps. | |
# You most likely have to compile more code as well, not only one file. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment