Skip to content

Commit

Permalink
refact(update-to-v4.8.1): Refactor dockerfile
Browse files Browse the repository at this point in the history
- Move to alpine to decrease image size
- Remove build deps after building
- Set production
- Make sure we exit the start script and have the daemon running as
  PID 1
- Use tags, not just plain master

Note: this obsoletes /polyfill/v2/ and must be requested as /v3/.
  • Loading branch information
Melvyn Sopacua committed Apr 2, 2019
1 parent ecb9d55 commit 3bec61c
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
# Node LTS
FROM node:8.11.3-slim

RUN apt-get update && \
apt-get install -y --no-install-recommends \
git=1:2.1.4-2.1+deb8u6 \
python=2.7.9-1 \
make=4.0-8.1 \
gcc=4:4.9.2-2 \
g++=4:4.9.2-2 \
libc6-dev=2.19-18+deb8u10 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/Financial-Times/polyfill-service.git /polyfill
FROM node:10.15.3-alpine

RUN apk add --no-cache --update bash
RUN apk add --no-cache --update --virtual build git python make gcc g++
WORKDIR /polyfill

RUN npm run install

ARG POLYFILL_TAG='v4.8.1'
ARG NODE_ENV='production'
RUN \
git clone https://github.com/Financial-Times/polyfill-service . && \
git checkout ${POLYFILL_TAG} && \
rm -rf .git && \
yarn install && \
sed -i.bak -e 's,^node,exec node,' start_server.sh && \
mv start_server.sh /bin/ && \
chmod a+x /bin/start_server.sh && \
apk del build
ENV PORT 8801
ENV NODE_ENV dev

EXPOSE ${PORT}

CMD ["node", "--optimize_for_size", "--max_old_space_size=460", "--gc_interval=100", "packages/polyfill-service/bin/polyfill-service"]
CMD ["/bin/start_server.sh", "server/index.js"]
# CMD ["/bin/sh", "-c", "sleep 3600"]

0 comments on commit 3bec61c

Please sign in to comment.