Commit a401c02c authored by Aleksey Shirokih's avatar Aleksey Shirokih
Browse files

alpine based image. multistage builds for debian image

parent 83203d64
.idea/*
.idea/
noc_tower.egg-info/
build/
dist/
root/
var/*
var/
pip-selfcheck.json
local/**
lib/*
include/*
bin/*
share/*
lib/
include/
share/
*.pyc
.idea/
include/
lib/
Would skip repository local/
share/
var/
\ No newline at end of file
......@@ -42,7 +42,7 @@ upload:
- tags
build_image:
stage: build_image
stage: build_image_debian
before_script:
- export VERSION=$(cat VERSION)
- export CONTAINER_NAME=$CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME
......@@ -59,3 +59,22 @@ build_image:
only:
- master
- tags
build_image:
stage: build_image_alpine
before_script:
- export VERSION=$(cat VERSION)
- export CONTAINER_NAME=$CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME_alpine
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker build --pull --build-arg="http_proxy=$PROXY" --build-arg="https_proxy=$PROXY" --build-arg=VERSION=${VERSION} -t $CONTAINER_NAME .
- docker push $CONTAINER_NAME
- if [ -n "${CI_BUILD_TAG}" ]; then docker tag $CONTAINER_NAME $CI_REGISTRY_IMAGE:${CI_BUILD_TAG}_alpine; docker push $CI_REGISTRY_IMAGE:${CI_BUILD_TAG}; fi
- if [ -n "${CI_BUILD_TAG}" ]; then docker tag $CONTAINER_NAME $CI_REGISTRY_IMAGE:alpine; docker push $CI_REGISTRY_IMAGE:latest; fi
dependencies:
- build_tgz
tags:
- shell
only:
- master
- tags
\ No newline at end of file
FROM debian:latest
FROM python:2.7 as builder
RUN mkdir /mnt/tower
WORKDIR /mnt/tower/
COPY . /mnt/tower/
RUN python setup.py sdist --format=zip
WORKDIR /opt/tower
RUN virtualenv /opt/tower && ./bin/pip install /mnt/tower/dist/*.zip
FROM debian:latest as app
ENV PATH /opt/tower/bin:${PATH}
ENV ANSIBLE_HOST_KEY_CHECKING=False \
ANSIBLE_SSH_PIPELINING=1 \
ANSIBLE_STDOUT_CALLBACK=debug \
PYTHONUNBUFFERED=1 \
VERSION=${VERSION}
VERSION=${VERSION} \
PYTHONPATH=/opt/tower/lib/python2.7:/usr/lib/python2.7
COPY --from=builder /opt/tower /opt/tower
# install systemv packages
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python-virtualenv \
libffi-dev \
python-dev gcc \
libpython2.7 \
libpython2.7-stdlib \
libpython-stdlib \
python2.7 \
python-minimal \
ca-certificates \
openssh-client \
libssl-dev \
vim-tiny \
sqlite3 \
curl \
telnet \
git \
&& rm -rf /var/cache/apk/* \
&& rm -rf /var/lib/apt/lists/* \
&& python /usr/lib/python2.7/dist-packages/virtualenv.py /opt/tower \
&& /opt/tower/bin/pip install https://cdn.getnoc.com/tower/noc-tower-latest.zip \
&& apt-get -y purge gcc libssl-dev libffi-dev
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt/tower
......
FROM alpine:3.6 as builder
RUN mkdir /mnt/tower
WORKDIR /mnt/tower/
COPY . /mnt/tower/
RUN apk add --update py2-cffi py-virtualenv gcc python-dev musl-dev libffi-dev openssl-dev ca-certificates
RUN python setup.py sdist --format=zip
WORKDIR /opt/tower
RUN virtualenv /opt/tower && ./bin/pip install /mnt/tower/dist/*.zip
FROM python:2.7-alpine3.6
ENV ANSIBLE_HOST_KEY_CHECKING=False \
ANSIBLE_SSH_PIPELINING=1 \
ANSIBLE_STDOUT_CALLBACK=debug \
PYTHONUNBUFFERED=1 \
VERSION=${VERSION}
VERSION=${VERSION} \
PYTHONPATH=/opt/tower/lib/python2.7/site-packages/:/usr/local/lib/python2.7:/usr/local/lib/python2.7/site-packages
COPY --from=builder /opt/tower /opt/tower
# install systemv packages
RUN apk add --update ca-certificates openssh-client vim sqlite curl git libffi-dev gcc musl-dev openssl-dev libffi\
&& mkdir -p /opt/tower \
&& pip install https://cdn.getnoc.com/tower/noc-tower-latest.zip \
&& apk del libffi-dev gcc musl-dev openssl-dev
RUN apk add --update ca-certificates openssh-client vim sqlite curl git libffi
WORKDIR /usr/local/
WORKDIR /opt/tower
COPY entrypoint-alpine.sh /
COPY entrypoint.sh /
STOPSIGNAL SIGINT
ENTRYPOINT ["/entrypoint-alpine.sh"]
ENTRYPOINT ["/entrypoint.sh"]
VOLUME /usr/local/var/tower/
VOLUME /opt/tower/var/
EXPOSE 8888
......@@ -2,15 +2,15 @@
set -xe
if [ ! -f /usr/local/var/tower/data/deploy_keys/id_rsa ]; then
mkdir -p /usr/local/var/tower/data/deploy_keys
ssh-keygen -t rsa -b 4096 -f /usr/local/var/tower/data/deploy_keys/id_rsa
chmod 0700 /usr/local/var/tower/data/deploy_keys/
cd /usr/local
mkdir -p /usr/local/var/tower/db /usr/local/var/tower/cache /usr/local/var/tower/repo
mkdir -p /usr/local/var/tower/log/jobs /usr/local/var/tower/log/crashinfo/collect
mkdir -p /usr/local/var/tower/ansible/cp /usr/local/var/tower/crashinfo
mkdir -p /usr/local/var/tower/data/src_dist/
if [ ! -f /opt/tower/var/tower/data/deploy_keys/id_rsa ]; then
mkdir -p /opt/tower/var/tower/data/deploy_keys
ssh-keygen -t rsa -b 4096 -f /opt/tower/var/tower/data/deploy_keys/id_rsa
chmod 0700 /opt/tower/var/tower/data/deploy_keys/
cd /opt/tower
mkdir -p /opt/tower/var/tower/db /opt/tower/var/tower/cache /opt/tower/var/tower/repo
mkdir -p /opt/tower/var/tower/log/jobs /opt/tower/var/tower/log/crashinfo/collect
mkdir -p /opt/tower/var/tower/ansible/cp /opt/tower/var/tower/crashinfo
mkdir -p /opt/tower/var/tower/data/src_dist/
fi
if [ $# -eq 0 ]; then
......
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