Last active
April 15, 2024 09:22
-
-
Save duongdam/7fbcdf02c38b58a61d3a18c5b9732136 to your computer and use it in GitHub Desktop.
Dockerfile for Bun API with size reduced to 298Mb
This file contains hidden or 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
#Simple size about 298Mb. Bun v1.0.21 | |
FROM oven/bun:latest as build-stage | |
WORKDIR /dist | |
COPY . . | |
COPY .env.production .env | |
COPY package.json package.json | |
COPY bun.lockb bun.lockb | |
# Firebase staging | |
#COPY firebase/stg.json stg.json | |
# Firebase Production | |
#COPY firebase/prod.json prod.json | |
RUN bun install | |
RUN bun build ./server.js --outfile server --compile | |
# Reduce image size | |
# FROM --platform=linux/amd64 oven/bun:latest if error occurs with platform, but in v1.0.0 it should be fixed | |
FROM oven/bun:latest | |
WORKDIR /app | |
COPY --from=build-stage /dist/.env ./.env | |
#COPY --from=build-stage /dist/stg.json ./firebase/stg.json | |
COPY --from=build-stage /dist/server ./server | |
EXPOSE 8080 | |
ENV PORT 8080 | |
# set hostname to localhost - Use when deploying to Google Cloud Run | |
ENV HOSTNAME "0.0.0.0" | |
CMD ["./server"] | |
# Simple source used Bun with express api,visit https://github.com/duongdam/bun-server-js (branch main and main-typescript) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment