mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 14:30:09 +01:00
update docker image gen
This commit is contained in:
parent
7835c8b337
commit
acfc861e58
3 changed files with 13 additions and 54 deletions
|
|
@ -5,7 +5,7 @@ stages:
|
||||||
|
|
||||||
unit:
|
unit:
|
||||||
stage: test
|
stage: test
|
||||||
image: registry.gitlab.com/mbarkhau/pycalver/base:latest
|
image: registry.gitlab.com/mbarkhau/pycalver/base
|
||||||
script:
|
script:
|
||||||
- make lint
|
- make lint
|
||||||
- make mypy
|
- make mypy
|
||||||
|
|
|
||||||
|
|
@ -1,59 +1,13 @@
|
||||||
# Stages:
|
# Stages:
|
||||||
# base_image : Common base image, both for the builder and for the final image.
|
# root : Common image, both for the builder and for the final image.
|
||||||
# This contains only minimal dependencies required in both cases
|
# This contains only minimal dependencies required in both cases
|
||||||
# for miniconda and the makefile.
|
# for miniconda and the makefile.
|
||||||
# builder : stage in which the conda envrionment is created
|
# env_builder: stage in which the conda envrionment is created
|
||||||
# and dependencies are installed
|
# and dependencies are installed
|
||||||
# final : the final image containing only the required environment files,
|
# base : the final image containing only the required environment files,
|
||||||
# and none of the infrastructure required to generate them.
|
# and none of the infrastructure required to generate them.
|
||||||
|
|
||||||
FROM debian:stable-slim AS base_image
|
FROM registry.gitlab.com/mbarkhau/bootstrapit/env_builder AS builder
|
||||||
|
|
||||||
ENV LC_ALL=C.UTF-8
|
|
||||||
ENV LANG=C.UTF-8
|
|
||||||
ENV LANGUAGE en_US.UTF-8
|
|
||||||
|
|
||||||
ENV CONDA_DIR /opt/conda
|
|
||||||
ENV PATH $CONDA_DIR/bin:$PATH
|
|
||||||
ENV SHELL /bin/bash
|
|
||||||
|
|
||||||
RUN if [ $(which apk) ]; then \
|
|
||||||
apk add --no-cache bash make sed grep gawk curl git bzip2 unzip; \
|
|
||||||
elif [ $(which apt-get) ]; then \
|
|
||||||
apt-get update && apt-get install --yes bash make sed grep gawk curl git bzip2 unzip; \
|
|
||||||
else \
|
|
||||||
echo "Invalid Distro: $(uname -a)"; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
CMD [ "/bin/bash" ]
|
|
||||||
|
|
||||||
FROM base_image AS builder
|
|
||||||
|
|
||||||
RUN if [ $(which apk) ]; then \
|
|
||||||
apk add --no-cache ca-certificates openssh-client openssh-keygen; \
|
|
||||||
elif [ $(which apt-get) ]; then \
|
|
||||||
apt-get --yes install ca-certificates openssh-client; \
|
|
||||||
else \
|
|
||||||
echo "Invalid Distro: $(uname -a)"; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
ENV MINICONDA_VER latest
|
|
||||||
ENV MINICONDA Miniconda3-$MINICONDA_VER-Linux-x86_64.sh
|
|
||||||
ENV MINICONDA_URL https://repo.continuum.io/miniconda/$MINICONDA
|
|
||||||
|
|
||||||
RUN curl -L "$MINICONDA_URL" --silent -o miniconda3.sh && \
|
|
||||||
/bin/bash miniconda3.sh -f -b -p $CONDA_DIR && \
|
|
||||||
rm miniconda3.sh && \
|
|
||||||
/opt/conda/bin/conda clean -tipsy && \
|
|
||||||
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
|
|
||||||
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
|
|
||||||
echo "conda activate base" >> ~/.bashrc && \
|
|
||||||
conda update --all --yes && \
|
|
||||||
conda config --set auto_update_conda False
|
|
||||||
|
|
||||||
# Project specific files only from here on forward
|
|
||||||
|
|
||||||
RUN mkdir /root/.ssh/ && \
|
RUN mkdir /root/.ssh/ && \
|
||||||
ssh-keyscan gitlab.com >> /root/.ssh/known_hosts && \
|
ssh-keyscan gitlab.com >> /root/.ssh/known_hosts && \
|
||||||
|
|
@ -103,7 +57,7 @@ RUN conda clean --all --yes && \
|
||||||
rm -rf /opt/conda/pkgs/
|
rm -rf /opt/conda/pkgs/
|
||||||
|
|
||||||
|
|
||||||
FROM base_image
|
FROM registry.gitlab.com/mbarkhau/bootstrapit/root
|
||||||
|
|
||||||
COPY --from=builder /opt/conda/ /opt/conda/
|
COPY --from=builder /opt/conda/ /opt/conda/
|
||||||
COPY --from=builder /vendor/ /vendor
|
COPY --from=builder /vendor/ /vendor
|
||||||
|
|
|
||||||
9
makefile
9
makefile
|
|
@ -60,7 +60,10 @@ DEV_ENV_PY := $(DEV_ENV)/bin/python
|
||||||
|
|
||||||
RSA_KEY_PATH := ${HOME}/.ssh/${PKG_NAME}_gitlab_runner_id_rsa
|
RSA_KEY_PATH := ${HOME}/.ssh/${PKG_NAME}_gitlab_runner_id_rsa
|
||||||
|
|
||||||
DOCKER_BASE_IMAGE := registry.gitlab.com/mbarkhau/pycalver/base:latest
|
DOCKER_BASE_IMAGE := registry.gitlab.com/mbarkhau/pycalver/base
|
||||||
|
|
||||||
|
DOCKER_IMAGE_VERSION := $(shell date -u +'%Y%m%dt%H%M%S')_$(shell git rev-parse --short HEAD)
|
||||||
|
|
||||||
|
|
||||||
build/envs.txt: requirements/conda.txt
|
build/envs.txt: requirements/conda.txt
|
||||||
@mkdir -p build/;
|
@mkdir -p build/;
|
||||||
|
|
@ -368,7 +371,7 @@ check: fmt lint mypy test
|
||||||
env_subshell:
|
env_subshell:
|
||||||
@bash --init-file <(echo '\
|
@bash --init-file <(echo '\
|
||||||
source $$HOME/.bashrc; \
|
source $$HOME/.bashrc; \
|
||||||
source $(CONDA_ROOT)/etc/profile.d/conda.sh; \
|
source $(CONDA_ROOT)/etc/profile.d/conda.sh \
|
||||||
export ENV=$${ENV-dev}; \
|
export ENV=$${ENV-dev}; \
|
||||||
export PYTHONPATH="src/:vendor/:$$PYTHONPATH"; \
|
export PYTHONPATH="src/:vendor/:$$PYTHONPATH"; \
|
||||||
conda activate $(DEV_ENV_NAME) \
|
conda activate $(DEV_ENV_NAME) \
|
||||||
|
|
@ -510,11 +513,13 @@ build_docker:
|
||||||
docker build \
|
docker build \
|
||||||
--build-arg SSH_PRIVATE_RSA_KEY="$$(cat '${RSA_KEY_PATH}')" \
|
--build-arg SSH_PRIVATE_RSA_KEY="$$(cat '${RSA_KEY_PATH}')" \
|
||||||
--file docker_base.Dockerfile \
|
--file docker_base.Dockerfile \
|
||||||
|
--tag $(DOCKER_BASE_IMAGE):$(DOCKER_IMAGE_VERSION) \
|
||||||
--tag $(DOCKER_BASE_IMAGE) \
|
--tag $(DOCKER_BASE_IMAGE) \
|
||||||
.; \
|
.; \
|
||||||
else \
|
else \
|
||||||
docker build \
|
docker build \
|
||||||
--file docker_base.Dockerfile \
|
--file docker_base.Dockerfile \
|
||||||
|
--tag $(DOCKER_BASE_IMAGE):$(DOCKER_IMAGE_VERSION) \
|
||||||
--tag $(DOCKER_BASE_IMAGE) \
|
--tag $(DOCKER_BASE_IMAGE) \
|
||||||
.; \
|
.; \
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue