feat(docker): Shrink Docker image size
This commit is contained in:
Родитель
e2f995e9ef
Коммит
00f3e70759
|
@ -1,19 +1,19 @@
|
|||
FROM node:4.5.0
|
||||
FROM mhart/alpine-node:4.7.2
|
||||
|
||||
RUN groupadd --gid 10001 app && \
|
||||
useradd --uid 10001 --gid 10001 --home /app --create-home app
|
||||
RUN addgroup -g 10001 app && \
|
||||
adduser -D -G app -h /app -u 10001 app
|
||||
WORKDIR /app
|
||||
|
||||
# S3 bucket in Cloud Services prod IAM
|
||||
ADD https://s3.amazonaws.com/dumb-init-dist/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
|
||||
RUN chmod +x /usr/local/bin/dumb-init
|
||||
ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
|
||||
|
||||
USER app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY npm-shrinkwrap.json npm-shrinkwrap.json
|
||||
COPY package.json package.json
|
||||
|
||||
RUN npm install && \
|
||||
npm cache clear && \
|
||||
rm -rf ~app/.node-gyp ~app/.npm
|
||||
RUN npm install --production && rm -rf ~app/.npm /tmp/*
|
||||
|
||||
COPY . /app
|
||||
|
||||
ENTRYPOINT ["/app/scripts/docker-exec.sh"]
|
||||
CMD ["test"]
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
FROM fxa-basket-proxy:build
|
||||
RUN npm install
|
|
@ -21,11 +21,12 @@ dependencies:
|
|||
"$CIRCLE_BUILD_URL"
|
||||
| tee config/version.json version.json
|
||||
|
||||
- docker build -f Dockerfile-build -t app:build .
|
||||
- docker build -f Dockerfile-build -t fxa-basket-proxy:build .
|
||||
- docker build -f Dockerfile-test -t fxa-basket-proxy:test .
|
||||
|
||||
test:
|
||||
override:
|
||||
- docker run app:build test
|
||||
- docker run fxa-basket-proxy:test npm test
|
||||
|
||||
# appropriately tag and push the container to dockerhub
|
||||
deployment:
|
||||
|
@ -34,7 +35,7 @@ deployment:
|
|||
commands:
|
||||
- "[ ! -z $DOCKERHUB_REPO ]"
|
||||
- docker login -e "$DOCKER_EMAIL" -u "$DOCKER_USER" -p "$DOCKER_PASS"
|
||||
- "docker tag app:build ${DOCKERHUB_REPO}:latest"
|
||||
- "docker tag fxa-basket-proxy:build ${DOCKERHUB_REPO}:latest"
|
||||
- "docker push ${DOCKERHUB_REPO}:latest"
|
||||
|
||||
hub_releases:
|
||||
|
@ -44,6 +45,6 @@ deployment:
|
|||
- "[ ! -z $DOCKERHUB_REPO ]"
|
||||
- docker login -e "$DOCKER_EMAIL" -u "$DOCKER_USER" -p "$DOCKER_PASS"
|
||||
- "echo ${DOCKERHUB_REPO}:${CIRCLE_TAG}"
|
||||
- "docker tag app:build ${DOCKERHUB_REPO}:${CIRCLE_TAG}"
|
||||
- "docker tag fxa-basket-proxy:build ${DOCKERHUB_REPO}:${CIRCLE_TAG}"
|
||||
- "docker images"
|
||||
- "docker push ${DOCKERHUB_REPO}:${CIRCLE_TAG}"
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ "$1" == "test" ]; then
|
||||
exec npm test
|
||||
elif [ "$1" == "web" ]; then
|
||||
exec node bin/basket-proxy-server.js
|
||||
elif [ "$1" == "worker" ]; then
|
||||
exec node basket-event-handler.js
|
||||
else
|
||||
echo "unknown mode: $1"
|
||||
exit 1
|
||||
fi
|
Загрузка…
Ссылка в новой задаче