Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

Shrink docker image with multi-stage build (#269)

Matthew Precious0e8f750654d6
diff --git a/Dockerfile b/Dockerfile
index 21871d973..c0933cd97 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,22 +1,27 @@
-FROM node:alpine
+FROM node:alpine as build
-RUN mkdir -p /usr/src/app
-ENV PORT 3000
-ARG DATABASE_URL
-ENV DATABASE_URL $DATABASE_URL
+WORKDIR /app
-WORKDIR /usr/src/app
-
-COPY package.json /usr/src/app
-COPY yarn.lock /usr/src/app
-COPY prisma/schema.prisma /usr/src/app
+COPY package.json .
+COPY yarn.lock .
+COPY prisma/schema.prisma .
RUN yarn --frozen-lockfile
-COPY . /usr/src/app
+COPY . .
RUN yarn build
+FROM node:alpine
+
+ENV PORT 3000
EXPOSE 3000
+ARG DATABASE_URL
+ENV DATABASE_URL $DATABASE_URL
+
+WORKDIR /usr/src/app
+
+COPY --from=build /app .
+
CMD [ "yarn", "start" ]
\ No newline at end of file