2019-10-02 10:02:24 +00:00
|
|
|
# Mutistaged Node.js Build
|
|
|
|
FROM node:10-alpine as builder
|
2017-06-15 15:56:30 +00:00
|
|
|
|
2019-10-02 10:02:24 +00:00
|
|
|
# Install system dependencies
|
|
|
|
RUN set -ex; \
|
|
|
|
apk add --update --no-cache \
|
2019-10-19 11:21:01 +00:00
|
|
|
make gcc g++ git python
|
2018-12-25 17:07:03 +00:00
|
|
|
|
2019-10-02 10:02:24 +00:00
|
|
|
# Copy package.json dependencies
|
2018-12-25 17:07:03 +00:00
|
|
|
COPY server/package.json /app/server/package.json
|
2019-04-15 18:53:36 +00:00
|
|
|
COPY server/package-lock.json /app/server/package-lock.json
|
2018-12-25 17:07:03 +00:00
|
|
|
COPY client/package.json /app/client/package.json
|
2019-04-15 18:53:36 +00:00
|
|
|
COPY client/package-lock.json /app/client/package-lock.json
|
2018-12-25 17:07:03 +00:00
|
|
|
COPY shared/package.json /app/shared/package.json
|
2019-04-15 18:53:36 +00:00
|
|
|
COPY shared/package-lock.json /app/shared/package-lock.json
|
2018-12-25 17:07:03 +00:00
|
|
|
COPY zone-mta/package.json /app/zone-mta/package.json
|
2019-04-15 18:53:36 +00:00
|
|
|
COPY zone-mta/package-lock.json /app/zone-mta/package-lock.json
|
2018-12-25 13:39:28 +00:00
|
|
|
|
2019-10-02 10:02:24 +00:00
|
|
|
# Install dependencies in each directory
|
2019-12-05 11:00:07 +00:00
|
|
|
RUN cd /app/client && npm install
|
|
|
|
RUN cd /app/shared && npm install --production
|
|
|
|
RUN cd /app/server && npm install --production
|
|
|
|
RUN cd /app/zone-mta && npm install --production
|
2018-12-25 13:39:28 +00:00
|
|
|
|
|
|
|
# Later, copy the app files. That improves development speed as buiding the Docker image will not have
|
2017-06-24 23:17:00 +00:00
|
|
|
# to download and install all the NPM dependencies every time there's a change in the source code
|
2018-12-25 17:07:03 +00:00
|
|
|
COPY . /app
|
2018-12-25 13:39:28 +00:00
|
|
|
|
2019-10-02 10:02:24 +00:00
|
|
|
RUN set -ex; \
|
2019-12-05 11:00:07 +00:00
|
|
|
cd /app/client && \
|
|
|
|
npm run build && \
|
|
|
|
rm -rf node_modules
|
2019-10-02 10:02:24 +00:00
|
|
|
|
|
|
|
# Final Image
|
|
|
|
FROM node:10-alpine
|
|
|
|
|
|
|
|
WORKDIR /app/
|
|
|
|
|
|
|
|
# Install system dependencies
|
|
|
|
RUN set -ex; \
|
|
|
|
apk add --update --no-cache \
|
|
|
|
pwgen netcat-openbsd bash imagemagick
|
|
|
|
|
|
|
|
COPY --from=builder /app/ /app/
|
2018-12-25 13:39:28 +00:00
|
|
|
|
2018-12-25 17:07:03 +00:00
|
|
|
EXPOSE 3000 3003 3004
|
|
|
|
ENTRYPOINT ["bash", "/app/docker-entrypoint.sh"]
|