Last active
January 11, 2025 01:25
-
-
Save isimmons/2c617f3dff5e1ab6f57c46566b8fd9a2 to your computer and use it in GitHub Desktop.
remix-run react-router docker files
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
FROM oven/bun:1 AS dependencies-env | |
COPY . /app | |
FROM dependencies-env AS development-dependencies-env | |
COPY ./package.json bun.lockb /app/ | |
WORKDIR /app | |
RUN bun i --frozen-lockfile | |
FROM dependencies-env AS production-dependencies-env | |
COPY ./package.json bun.lockb /app/ | |
WORKDIR /app | |
RUN bun i --production | |
FROM dependencies-env AS build-env | |
COPY ./package.json bun.lockb /app/ | |
COPY --from=development-dependencies-env /app/node_modules /app/node_modules | |
WORKDIR /app | |
RUN bun run build | |
FROM dependencies-env | |
COPY ./package.json bun.lockb /app/ | |
COPY --from=production-dependencies-env /app/node_modules /app/node_modules | |
COPY --from=build-env /app/build /app/build | |
WORKDIR /app | |
CMD ["bun", "run", "start"] |
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
# base image install pnpm and copy app | |
FROM node:20-alpine AS base | |
RUN npm i -g pnpm | |
COPY . /app | |
# all-dependencies required for both dev and build | |
FROM base AS all-dependencies | |
COPY ./package.json pnpm-lock.yaml /app/ | |
WORKDIR /app | |
RUN pnpm i --frozen-lockfile | |
# production build | |
FROM all-dependencies AS prod-build | |
WORKDIR /app | |
RUN pnpm build | |
# --target=dev | |
FROM all-dependencies AS dev | |
WORKDIR /app | |
CMD ["pnpm", "dev"] | |
# --target=prod | |
FROM base AS prod | |
COPY --from=prod-build /app/build /app/build | |
WORKDIR /app | |
# Install only production dependencies for the final image | |
COPY ./package.json pnpm-lock.yaml /app/ | |
RUN pnpm i --prod --frozen-lockfile | |
CMD ["pnpm", "start"] |
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
# Using npm | |
FROM node:20-alpine AS development-dependencies-env | |
COPY . /app | |
WORKDIR /app | |
RUN npm ci | |
FROM node:20-alpine AS production-dependencies-env | |
COPY ./package.json package-lock.json /app/ | |
WORKDIR /app | |
RUN npm ci --omit=dev | |
FROM node:20-alpine AS build-env | |
COPY . /app/ | |
COPY --from=development-dependencies-env /app/node_modules /app/node_modules | |
WORKDIR /app | |
RUN npm run build | |
FROM node:20-alpine | |
COPY ./package.json package-lock.json /app/ | |
COPY --from=production-dependencies-env /app/node_modules /app/node_modules | |
COPY --from=build-env /app/build /app/build | |
WORKDIR /app | |
CMD ["npm", "run", "start"] |
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
FROM node:20-alpine AS dependencies-env | |
RUN npm i -g pnpm | |
COPY . /app | |
FROM dependencies-env AS development-dependencies-env | |
COPY ./package.json pnpm-lock.yaml /app/ | |
WORKDIR /app | |
RUN pnpm i --frozen-lockfile | |
FROM dependencies-env AS production-dependencies-env | |
COPY ./package.json pnpm-lock.yaml /app/ | |
WORKDIR /app | |
RUN pnpm i --prod --frozen-lockfile | |
FROM dependencies-env AS build-env | |
COPY ./package.json pnpm-lock.yaml /app/ | |
COPY --from=development-dependencies-env /app/node_modules /app/node_modules | |
WORKDIR /app | |
RUN pnpm build | |
FROM dependencies-env | |
COPY ./package.json pnpm-lock.yaml /app/ | |
COPY --from=production-dependencies-env /app/node_modules /app/node_modules | |
COPY --from=build-env /app/build /app/build | |
WORKDIR /app | |
CMD ["pnpm", "start"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Had to use Dockerfile as the extension to make syntax highlighting work. I found some suggested file comment methods but they didn't work.