Skip to content

Commit

Permalink
chore: make docker image smaller
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoffroy Empain committed Sep 16, 2020
1 parent 25e71d0 commit 354c83f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
@@ -1,5 +1,6 @@
node_modules
build
.idea
tmp
coverage
data
dist
11 changes: 11 additions & 0 deletions docker/dev.runner.Dockerfile
@@ -0,0 +1,11 @@
FROM node:12-alpine

COPY ./dist/runner.js /app/dist/
COPY ./dist/runner.js.map /app/dist/
COPY ./node_modules /app/node_modules

WORKDIR /app

LABEL maintainer="pmbot.io"

CMD ["node", "dist/runner.js"]
20 changes: 20 additions & 0 deletions docker/dev.server.Dockerfile
@@ -0,0 +1,20 @@
FROM node:12-alpine

COPY ./dist/server.js /app//dist/
COPY ./dist/server.js.map /app//dist/
COPY ./node_modules/ /app/node_modules
COPY ./migrate-mongo-config.js /app/

RUN mkdir -p /app/migrations

WORKDIR /app

VOLUME /secrets

LABEL maintainer="pmbot.io"

ENV METROLINE_PORT=80

EXPOSE 80

CMD ["node", "dist/server.js"]
5 changes: 3 additions & 2 deletions docker/runner.Dockerfile
Expand Up @@ -5,8 +5,9 @@ COPY ./ /repo/
WORKDIR /repo

RUN apk add --no-cache git \
&& npm install \
&& npm run build
&& npm ci \
&& npm run build \
&& npm prune --production

FROM node:12-alpine

Expand Down
5 changes: 3 additions & 2 deletions docker/server.Dockerfile
Expand Up @@ -5,8 +5,9 @@ COPY ./ /repo/
WORKDIR /repo

RUN apk add --no-cache git \
&& npm install \
&& npm run build
&& npm ci \
&& npm run build \
&& npm prune --production

FROM node:12-alpine

Expand Down
4 changes: 2 additions & 2 deletions scripts/build.sh
Expand Up @@ -2,6 +2,6 @@ npm i
npm run build
rm -rf node_modules
npm ci --production
docker build -t metroline/server -f ./docker/server.Dockerfile .
docker build -t metroline/runner -f ./docker/runner.Dockerfile .
docker build -t metroline/runner -f ./docker/dev.runner.Dockerfile .
docker build -t metroline/server -f ./docker/dev.server.Dockerfile .
npm i

0 comments on commit 354c83f

Please sign in to comment.