Skip to content

Commit

Permalink
swarm: convert cylc-dev Docker image to run on ubuntu:latest
Browse files Browse the repository at this point in the history
* Switch from miniconda to micromamba for faster builds.
* Change the base image of cylc-dev from miniconda to ubunutu.
  • Loading branch information
oliver-sanders committed Apr 26, 2023
1 parent 4f795e7 commit 579f5f2
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 52 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ __pycache__
!cylc
!dockerfiles/*
!setup*
!MANIFEST.in
96 changes: 47 additions & 49 deletions dockerfiles/cylc-dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,49 @@
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

FROM conda/miniconda3:latest

LABEL version="1.0" \
description="Image with Cylc installed with Conda from a working copy."

ARG CONDA_ENV="cylc-dev"
ARG CYLC_FLOW_DIR="./"

# suppress bizarre error messages
# mesg: ttyname failed: Inappropriate ioctl for device
RUN sed -i 's/mesg.*/tty -s \&\& &/' "$HOME/.profile"

# copy in cylc source files
COPY "$CYLC_FLOW_DIR" "cylc"

# install cylc dependencies
RUN apt-get update && \
# build-deps: build-essential
# run deps: procps, rsync
apt-get -qq -y install build-essential procps rsync tree && \
# install conda stuff
conda init bash && \
. ./usr/local/etc/profile.d/conda.sh && \
conda env create -n "${CONDA_ENV}" -f './cylc/conda-environment.yml' && \
conda clean -y --all && \
apt-get -y remove build-essential && \
apt-get autoclean && \
echo "conda activate $CONDA_ENV" >> $HOME/.bashrc && \
# tests require TMPDIR
# 1) The Mamba image
# This image has mamba installed, we use it to create and pack
# the required Conda environment.
FROM mambaorg/micromamba AS mamba

# create the environment
COPY conda-environment.yml .
RUN micromamba env create -f conda-environment.yml --prefix ./env

# pack the environment
RUN \
micromamba create -c conda-forge -n conda-pack conda-pack && \
micromamba run -n conda-pack conda-pack --prefix ./env -o ./packed-env.tar && \
pwd && \
mkdir ./venv && \
cd ./venv && \
tar -xf ../packed-env.tar && \
rm ../packed-env.tar


# 2) The Cylc image
# This has the Cylc Mamba environment installed and activated by default in
# Bash shells. However, it does not have Mamba installed.
FROM ubuntu:latest as cylc-dev

COPY --from=mamba /tmp/venv /venv
COPY ./ /cylc

SHELL ["/bin/bash", "-c", "-l"]
ENTRYPOINT /bin/bash

# wipe the default crud then auto-activate the Cylc Mamba environment
RUN \
rm $HOME/.bashrc && \
echo '. /venv/bin/activate' >> $HOME/.bashrc && \
echo "export TMPDIR=/tmp" >> $HOME/.bashrc

# run setup logic
RUN . $HOME/.bashrc && \
pip install -e ./cylc[all] && \
cylc version
# unpack the Mamba environment, then install Cylc into it from source
RUN \
/venv/bin/conda-unpack && \
pip install --no-deps -e /cylc coverage && \
pip cache purge && \
cylc version --long

# install system dependencies
RUN \
apt-get update && \
apt-get -qq -y install procps rsync tree at && \
apt-get autoclean
9 changes: 6 additions & 3 deletions dockerfiles/cylc-remote/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ LABEL version="1.0" \
description="Cylc remote job host for background & at jobs."

# install deps
RUN apt-get -qq -y install at ssh && \
RUN \
apt-get -qq -y install ssh iputils-ping && \
apt-get autoclean

# copy public ssh key (don't setup two way ssh)
COPY .docker-ssh-keys/*.pub .ssh/

# authorise that key
RUN mkdir ~/.ssh -p && \
RUN \
mkdir ~/.ssh -p && \
chmod 700 ~/.ssh && \
touch ~/.ssh/authorized_keys && \
chmod 600 ~/.ssh/authorized_keys && \
Expand All @@ -40,7 +42,8 @@ EXPOSE 22
COPY dockerfiles/cylc-remote/configure bin/host-configure

# configure on boot and start the required services
ENTRYPOINT service ssh start && \
ENTRYPOINT \
service ssh start && \
atd && \
/bin/host-configure && \
/usr/bin/env bash

0 comments on commit 579f5f2

Please sign in to comment.