Dockerfile
1 # syntax = docker/dockerfile:1 2 3 # Adjust NODE_VERSION as desired 4 ARG NODE_VERSION=18.18.2 5 FROM node:${NODE_VERSION}-slim as base 6 7 LABEL fly_launch_runtime="Node.js" 8 9 # Node.js app lives here 10 WORKDIR /app 11 12 # Set production environment 13 ENV NODE_ENV="production" 14 ARG YARN_VERSION=1.22.21 15 RUN npm install -g yarn@$YARN_VERSION --force 16 17 18 # Throw-away build stage to reduce size of final image 19 FROM base as build 20 21 # Install packages needed to build node modules 22 RUN apt-get update -qq && \ 23 apt-get install -y build-essential pkg-config python-is-python3 24 25 # Install node modules 26 # COPY --link package.json yarn.lock ./ 27 # RUN yarn install --dev --frozen-lockfile 28 29 # Copy application code 30 COPY . . 31 RUN yarn install 32 RUN yarn build 33 34 # Final stage for app image 35 FROM base 36 37 # Copy built application 38 COPY --from=build /app /app 39 40 # Start the server by default, this can be overwritten at runtime 41 EXPOSE 3000 42 ENV HOST=0.0.0.0 43 ENV PORT=3000 44 CMD [ "yarn", "start" ]