Created
August 1, 2023 10:16
-
-
Save MarceloPrado/edf284331221cac1cff242ed89f32053 to your computer and use it in GitHub Desktop.
Fly.io Dockerfile
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
# ------------------------------ | |
# 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