Verified Commit efcb50af authored by Aleksey Shirokih's avatar Aleksey Shirokih
Browse files

Speedup docker release images build with targeted builds

parent 463e39da
FROM alpine:3.8
FROM alpine:3.10 AS code
MAINTAINER Aleksey Shirokih <shirokih@nocproject.org>
......@@ -39,7 +39,7 @@ RUN apk add --update --no-cache \
&& python ./scripts/deploy/install-packages requirements/card.json \
&& python ./scripts/deploy/install-packages requirements/bi.json \
&& find /opt/noc/ -type f -name "*.py" -print0 | xargs -0 python -m py_compile \
&& /usr/bin/cythonize -i speedup/*.pyx \
&& /usr/bin/cythonize2 -i speedup/*.pyx \
&& apk del -r .build-deps \
&& adduser -h /opt/noc -s /bin/sh -S -D -H -u 1200 noc \
&& chown noc /opt/noc
......@@ -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
FROM alpine:3.8
FROM alpine:3.10
MAINTAINER Aleksey Shirokih <shirokih@nocproject.org>
......@@ -39,4 +39,4 @@ RUN pip install --no-cache --trusted-host cdn.getnoc.com --find-links https://cd
COPY . /opt/noc
RUN find /opt/noc/ -type f -name "*.py" -print0 | xargs -0 python -m py_compile \
&& /usr/bin/cythonize -i speedup/*.pyx
&& /usr/bin/cythonize2 -i speedup/*.pyx
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