Commit 00384d00 authored by Jose Borreguero's avatar Jose Borreguero
Browse files

split docker configuration for localdev and CI


Signed-off-by: default avatarJose Borreguero <borreguero@gmail.com>
parent 52e9f320
Pipeline #196593 failed with stages
in 7 minutes and 4 seconds
......@@ -22,9 +22,13 @@ stages:
# download docker-compose executable
- curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o ./docker-compose
- chmod +x ./docker-compose
- \cp cfg/.env-ci .env
- \cp cfg/Dockerfile-ci Dockerfile
- \cp cfg/docker-compose-ci.yml docker-compose.yml
.docker-teardown: &docker-teardown
- ./docker-compose down -v
# remove containers, images, volumes, and networks created by this pipeline
- docker system prune -f -a --volumes
- sudo chown -R gitlab-runner . # allows "docker system prune" next time the pipeline runs
......@@ -52,7 +56,6 @@ dockerbuild:
before_script:
- *docker-setup
script:
- mv .env.ci .env
- docker build -t ${IMAGE_NAMETAG} . # create image with default Dockerfile
- docker push ${IMAGE_NAMETAG} # upload to the Container Registry
after_script:
......@@ -68,7 +71,6 @@ test:
script:
- docker pull ${IMAGE_NAMETAG} # pull from the Container Registry
- docker tag ${IMAGE_NAMETAG} djrems # retag the image
- \cp .env.ci .env
- ./docker-compose up -d
- docker exec -t service_djrems bash -c "make test"
after_script:
......
......@@ -8,9 +8,6 @@ ENV LANGUAGE en_US.UTF-8
ENV LC_COLLATE C
ENV LC_CTYPE en_US.UTF-8
WORKDIR /opt/django_remote_submission
COPY . .
# This line will throw error if using an old miniconda3 image.
# To correct, one must build a miniconda3 image while piling all apt-get statements together into one
# https://hub.docker.com/r/continuumio/miniconda3/dockerfile
......
......@@ -93,7 +93,9 @@ dockercleanall: ## delete ALL containers, images, and volumes
docker system prune -f -a --volumes
dockerbuilddev: ## create docker image for testing
/bin/cp .env.ci .env
\cp cfg/.env-localdev .env
\cp cfg/Dockerfile-localdev Dockerfile
\cp cfg/docker-compose-localdev.yml docker-compose.yml
docker build --network host -t djrems .
dockerup: ## start the docker container running the application. Assumes the image has been built
......
TEST_SERVER_HOSTNAME=djrems
TEST_SERVER_PORT=22
TEST_REMOTE_USER=testuser
TEST_REMOTE_PASSWORD=p4ssw0rd
TEST_REMOTE_DIRECTORY=/tmp
TEST_REMOTE_FILENAME=jobtest.py
TEST_PYTHON_PATH=python
TEST_PYTHON_ARGUMENTS=-u
# latest miniconda3 image
FROM continuumio/miniconda3
ENV PYTHONUNBUFFERED 1
ENV CFLAGS "-std=c++11"
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
ENV LC_COLLATE C
ENV LC_CTYPE en_US.UTF-8
WORKDIR /opt/django_remote_submission
COPY . .
# This line will throw error if using an old miniconda3 image.
# To correct, one must build a miniconda3 image while piling all apt-get statements together into one
# https://hub.docker.com/r/continuumio/miniconda3/dockerfile
RUN apt-get update && apt-get install -y emacs iputils-ping less make mlocate net-tools openssh-client openssh-server vim
RUN conda install --name base -c conda-forge mamba
RUN mamba env update --name base --file conda.environment/environment-dev.yml
# Will start conda environment when $HOME/.bashrc is invoked
# Critical to prepend .bashrc, otherwise the conda environment
# will not be activated when executing commands via remote SSH
RUN echo "$(echo "conda activate base"; cat /etc/skel/.bashrc)" > /etc/skel/.bashrc
RUN echo "$(echo "source /etc/profile.d/conda.sh"; cat /etc/skel/.bashrc)" > /etc/skel/.bashrc
RUN echo "$(echo "# Activate Conda Environment base"; cat /etc/skel/.bashrc)" > /etc/skel/.bashrc
# latest miniconda3 image
FROM continuumio/miniconda3
ENV PYTHONUNBUFFERED 1
ENV CFLAGS "-std=c++11"
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
ENV LC_COLLATE C
ENV LC_CTYPE en_US.UTF-8
# This line will throw error if using an old miniconda3 image.
# To correct, one must build a miniconda3 image while piling all apt-get statements together into one
# https://hub.docker.com/r/continuumio/miniconda3/dockerfile
RUN apt-get update && apt-get install -y emacs iputils-ping less make mlocate net-tools openssh-client openssh-server vim
RUN conda install --name base -c conda-forge mamba
RUN mamba env update --name base --file conda.environment/environment-dev.yml
# Will start conda environment when $HOME/.bashrc is invoked
# Critical to prepend .bashrc, otherwise the conda environment
# will not be activated when executing commands via remote SSH
RUN echo "$(echo "conda activate base"; cat /etc/skel/.bashrc)" > /etc/skel/.bashrc
RUN echo "$(echo "source /etc/profile.d/conda.sh"; cat /etc/skel/.bashrc)" > /etc/skel/.bashrc
RUN echo "$(echo "# Activate Conda Environment base"; cat /etc/skel/.bashrc)" > /etc/skel/.bashrc
#use for local development
version: '3'
services:
djrems:
restart: always
image: djrems
container_name: service_djrems
hostname: djrems
expose:
- "22"
env_file:
- .env
volumes:
- ./docker-entrypoint.sh:/usr/bin/docker-entrypoint.sh
- artifacts:/opt/django_remote_submission/artifacts
command: /usr/bin/docker-entrypoint.sh
volumes:
artifacts:
#use for local development
version: '3'
services:
djrems:
restart: always
image: djrems
container_name: service_djrems
hostname: djrems
expose:
- "22"
env_file:
- .env
volumes:
- ./docker-entrypoint.sh:/usr/bin/docker-entrypoint.sh
- artifacts:/opt/django_remote_submission/artifacts
- type: bind
source: ./
target: /opt/django_remote_submission
command: /usr/bin/docker-entrypoint.sh
volumes:
artifacts:
......@@ -16,6 +16,9 @@ services:
volumes:
- ./docker-entrypoint.sh:/usr/bin/docker-entrypoint.sh
- artifacts:/opt/django_remote_submission/artifacts
- type: bind
source: ./
target: /opt/django_remote_submission
command: /usr/bin/docker-entrypoint.sh
volumes:
......
Markdown is supported
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