Skip to content

Instantly share code, notes, and snippets.

@MarceloPrado
Created August 1, 2023 10:16
Show Gist options
  • Save MarceloPrado/edf284331221cac1cff242ed89f32053 to your computer and use it in GitHub Desktop.
Save MarceloPrado/edf284331221cac1cff242ed89f32053 to your computer and use it in GitHub Desktop.
Fly.io Dockerfile
# ------------------------------
# First stage: build the app
# This includes all dependencies.
# ------------------------------
FROM node:16.19-alpine as builder
ARG PORT
WORKDIR /app
# Install dependencies
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
COPY . .
# Build the app
RUN yarn run build:ci
# ------------------------------
# Second stage: the actual production image
# This includes only the runtime and the app itself.
# ------------------------------
FROM node:16.19-alpine
# Create app directory
WORKDIR /app
# Install app dependencies
COPY --from=builder /app/package.json /app/yarn.lock ./
COPY --from=builder /app/dist ./dist
# Move schema to the root of the project, since that's what Prisma expects
RUN mv ./dist/prisma ./prisma
RUN yarn install --production --frozen-lockfile
# Railway and Fly.io require host to be this - https://docs.railway.app/deploy/exposing-your-app
ENV HOST="0.0.0.0"
EXPOSE $PORT
CMD [ "yarn", "start:prod" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment