Commit 5da383d9 authored by Aleksey Shirokih's avatar Aleksey Shirokih
Browse files

Merge branch 'docker_better_build' into 'master'

Speedup docker release images build with targeted builds

See merge request noc/noc!2358
parents bf5a1dfd 553e4b37
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
......@@ -315,53 +315,16 @@ Build Master Docs:
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