Skip to content

Commit

Permalink
Docker multi-stage build
Browse files Browse the repository at this point in the history
Remove Dockerfile.build
  • Loading branch information
motet-a committed Nov 13, 2017
1 parent 27553bc commit f758efd
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 34 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
/client/dist
/server/node_modules
/server/var
/build-output
29 changes: 26 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
FROM node:8.1.3-slim
FROM node:9

RUN apt-get update \
&& apt-get install -y --no-install-recommends python \
&& rm -rf /var/lib/apt/lists/*

ENV NODE_ENV=production

RUN mkdir -p /gs/server /gs/client
WORKDIR /gs

COPY server/package.json server/yarn.lock server/
RUN cd server && yarn

COPY client/package.json client/yarn.lock client/
RUN cd client && yarn install --production=false

COPY client/src client/src
COPY client/.babelrc client/webpack.config.js client/
RUN cd client && yarn run build



FROM node:9-slim

RUN apt-get update \
&& apt-get install -y --no-install-recommends git grep \
Expand All @@ -8,10 +31,10 @@ ENV NODE_ENV=production

RUN mkdir -p /gs/client

COPY build-output/gs/client/dist /gs/client/dist
COPY --from=0 /gs/client/dist /gs/client/dist
COPY client/index.html /gs/client/

COPY build-output/gs/server /gs/server
COPY --from=0 /gs/server /gs/server
COPY server/src /gs/server/src

WORKDIR /gs/server
Expand Down
20 changes: 0 additions & 20 deletions Dockerfile.build

This file was deleted.

8 changes: 0 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,4 @@

cd "$(dirname "$0")"

rm -Rf build-output
docker build -t gtsearch-build -f Dockerfile.build .
docker run -d --name gtsearch-build-1 gtsearch-build /bin/sh
mkdir build-output
docker cp gtsearch-build-1:/gs build-output
docker stop gtsearch-build-1
docker rm gtsearch-build-1

docker build -t gtsearch .
2 changes: 1 addition & 1 deletion client/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:8.1.3-alpine
FROM node:9-alpine

RUN mkdir -p /gs/client
WORKDIR /gs/client
Expand Down
2 changes: 1 addition & 1 deletion server/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:8.1.3
FROM node:9

RUN apt-get update \
&& apt-get install -y --no-install-recommends git \
Expand Down

0 comments on commit f758efd

Please sign in to comment.