Commit 4ca772a0 authored by Aleksey Shirokih's avatar Aleksey Shirokih Committed by Andrey Vertiprahov
Browse files

Merge branch 'docker_better_build' into 'master'

Speedup docker release images build with targeted builds

See merge request noc/noc!2358

(cherry picked from commit 5da383d9)

2db26a6b define environmets
19d9bc74 Merge branch 'master' of code.getnoc.com:noc/noc
716aee0f Add mongo-rs healthcheck. launch migrations on hc. Remove all other definitions except used
03b26995 Merge
36a3ab15 Merge branch 'master' of code.getnoc.com:noc/noc
ebbf12f2 Merge branch 'master' of code.getnoc.com:noc/noc
05710893 Merge branch 'master' of code.getnoc.com:noc/noc
463e39da Merge branch 'master' of code.getnoc.com:noc/noc
efcb50af Speedup docker release images build with targeted builds
553e4b37 Revert to alpine 3.8. Because of https://github.com/esnme/ultrajson/issues/326
parent 934873f3
FROM alpine:3.8
FROM alpine:3.8 AS code
MAINTAINER Aleksey Shirokih <shirokih@nocproject.org>
......@@ -48,3 +48,23 @@ EXPOSE 1200
VOLUME /opt/noc
VOLUME /usr/lib/python2.7/site-packages/django
FROM code AS dev
RUN apk add --update vim \
python-dev \
gcc musl-dev \
&& pip install pudb ipython \
&& apk del python-dev gcc musl-dev \
&& rm -rf /var/cache/apk/* /root/.cache/pip
HEALTHCHECK NONE
FROM nginx:alpine AS static
RUN apk add --no-cache curl
COPY --from=code /usr/lib/python2.7/site-packages/django /usr/lib/python2.7/site-packages/django
COPY --from=code /opt/noc/ui /opt/noc/ui
ARG IMAGE=${IMAGE}
FROM $IMAGE
MAINTAINER Aleksey Shirokih <shirokih@nocproject.org>
RUN apk add --update vim \
python-dev \
gcc musl-dev \
&& pip install pudb ipython \
&& apk del python-dev gcc musl-dev \
&& rm -rf /var/cache/apk/* /root/.cache/pip
HEALTHCHECK NONE
ARG IMAGE=${IMAGE}
FROM $IMAGE
MAINTAINER Aleksey Shirokih <shirokih@nocproject.org>
FROM nginx:alpine
RUN apk add --no-cache curl
COPY --from=0 /usr/lib/python2.7/site-packages/django /usr/lib/python2.7/site-packages/django
COPY --from=0 /opt/noc/ui /opt/noc/ui
......@@ -197,53 +197,16 @@ Test python 3:
Build release image:
stage: Build release container
before_script:
# registry.getnoc.com/noc/noc/code:stable
- CONTAINER_NAME=$CI_REGISTRY_IMAGE/code:$CI_COMMIT_TAG
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker build -t $CONTAINER_NAME -f .docker/Dockerfile .
- docker push $CONTAINER_NAME
- docker rmi $CONTAINER_NAME
tags:
- shell
only:
- tags
Build nginx image:
stage: Build additional release containers
before_script:
# registry.getnoc.com/noc/noc/static:stable
- CONTAINER_NAME=$CI_REGISTRY_IMAGE/static:$CI_COMMIT_TAG
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- >
docker build
--no-cache
--build-arg IMAGE=$CI_REGISTRY_IMAGE/code:$CI_COMMIT_TAG
-t ${CONTAINER_NAME}
-f .docker/Dockerfile.static .
- docker push ${CONTAINER_NAME}
- docker rmi ${CONTAINER_NAME}
tags:
- shell
only:
- tags
Build dev image:
stage: Build additional release containers
before_script:
# registry.getnoc.com/noc/noc/code:stable
- docker build --target code -t $CI_REGISTRY_IMAGE/code:$CI_COMMIT_TAG -f .docker/Dockerfile .
# registry.getnoc.com/noc/noc/dev:stable
- CONTAINER_NAME=$CI_REGISTRY_IMAGE/dev:$CI_COMMIT_TAG
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- >
docker build
--no-cache
--build-arg IMAGE=$CI_REGISTRY_IMAGE/code:$CI_COMMIT_TAG
-t ${CONTAINER_NAME}
-f .docker/Dockerfile.dev .
- docker push ${CONTAINER_NAME}
- docker rmi ${CONTAINER_NAME}
- docker build --target dev -t $CI_REGISTRY_IMAGE/dev:$CI_COMMIT_TAG -f .docker/Dockerfile .
# registry.getnoc.com/noc/noc/static:stable
- docker build --target static -t $CI_REGISTRY_IMAGE/static:$CI_COMMIT_TAG -f .docker/Dockerfile .
- docker push $CI_REGISTRY_IMAGE/code:$CI_COMMIT_TAG $CI_REGISTRY_IMAGE/dev:$CI_COMMIT_TAG $CI_REGISTRY_IMAGE/static:$CI_COMMIT_TAG
- docker rmi $CI_REGISTRY_IMAGE/code:$CI_COMMIT_TAG $CI_REGISTRY_IMAGE/dev:$CI_COMMIT_TAG $CI_REGISTRY_IMAGE/static:$CI_COMMIT_TAG
tags:
- shell
only:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment