Skip to content

Instantly share code, notes, and snippets.

@scottmries
Last active October 24, 2023 18:17
Show Gist options
  • Save scottmries/0960608c7b8070d53f0b593f5b0bce72 to your computer and use it in GitHub Desktop.
Save scottmries/0960608c7b8070d53f0b593f5b0bce72 to your computer and use it in GitHub Desktop.
Portfolio site Dockerfile
# syntax = docker/dockerfile:1
FROM node:alpine as base
LABEL fly_launch_runtime="Next.js"
# Next.js app lives here
WORKDIR /app
# Set production environment
ENV NODE_ENV="production"
# Throw-away build stage to reduce size of final image
FROM base as build
# Install the correct glibc to run Bun
RUN if [[ $(uname -m) == "aarch64" ]] ; \
then \
# aarch64
wget https://raw.githubusercontent.com/squishyu/alpine-pkg-glibc-aarch64-bin/master/glibc-2.26-r1.apk ; \
apk add --no-cache --allow-untrusted --force-overwrite glibc-2.26-r1.apk ; \
rm glibc-2.26-r1.apk ; \
else \
# x86_64
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk ; \
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub ; \
apk add --no-cache --force-overwrite glibc-2.28-r0.apk ; \
rm glibc-2.28-r0.apk ; \
fi
RUN npm install -g bun
# Install node modules
COPY --link bun.lockb package.json ./
RUN bun install
# Copy application code
COPY --link . .
# Build application
RUN bun run build
# Remove development dependencies
RUN rm -rf node_modules && \
bun install --ci
# Final stage for app image
FROM base
# Copy built application
COPY --from=build /app /app
# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "npm", "run", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment