Skip to content

Instantly share code, notes, and snippets.

@iexa
Last active October 1, 2023 12:14
Show Gist options
  • Save iexa/af8d237aa82684cdb06e764171e4be96 to your computer and use it in GitHub Desktop.
Save iexa/af8d237aa82684cdb06e764171e4be96 to your computer and use it in GitHub Desktop.
Dockerfile tips
## NODE
##################################
# multi-stage build to exclude intermediate build files and keep only resulting artifacts
# -slim uses debian and is similar in size, alpine ~120 / -sim ~180mb, while full >1gb!
FROM node:16-alpine AS build
# FROM node:18-slim AS build
WORKDIR /app
COPY . .
RUN yarn install
# FROM gcr.io/distroless/nodejs18-debian11
FROM node:16-alpine
COPY --from=build /app /app
EXPOSE 3000
# react-scripts -> do not try to open browser window as it tries to use powershell even in docker
ENV BROWSER=none
# if using host/bind mounts from windows, volumes are fine
ENV WATCHPACK_POLLING=true
CMD ["yarn", "start"]
########################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment