From 3bec61c6043f3dc5f3657635c33d620cf8b618cb Mon Sep 17 00:00:00 2001 From: Melvyn Sopacua Date: Tue, 2 Apr 2019 10:52:04 +0200 Subject: [PATCH 1/2] refact(update-to-v4.8.1): Refactor dockerfile - 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/. --- Dockerfile | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index ca13afd..dc97175 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] From ad9c2e098e0d914ff43f34c62196503234723db9 Mon Sep 17 00:00:00 2001 From: Melvyn Sopacua Date: Sun, 2 Jun 2019 11:02:50 +0200 Subject: [PATCH 2/2] chore(update-to-v4.8.1): Add comment --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index dc97175..74a9548 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,5 +19,6 @@ ENV PORT 8801 EXPOSE ${PORT} CMD ["/bin/start_server.sh", "server/index.js"] +# Use to debug if things don't start: # CMD ["/bin/sh", "-c", "sleep 3600"]