-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
144 lines (122 loc) · 5.47 KB
/
Dockerfile
File metadata and controls
144 lines (122 loc) · 5.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# See https://github.com/phusion/baseimage-docker/blob/master/Changelog.md
# Based on Ubuntu 22.04
FROM phusion/baseimage:jammy-1.0.0
LABEL maintainer="AiiDA Team"
# Use the following arguments during *build* time:
# $ docker build --build-arg NB_UID=200
ARG NB_USER="aiida"
ARG NB_UID="1000"
ARG NB_GID="1000"
ARG TARGETARCH
# Use the following variables when running docker:
# $ docker run -e SYSTEM_USER=aiida2
ENV SYSTEM_USER ${NB_USER}
ENV SYSTEM_USER_UID ${NB_UID}
ENV SYSTEM_USER_GID ${NB_GID}
ENV CONDA_DIR /opt/conda
ENV PATH $CONDA_DIR/bin:$PATH
# Modify this section for the conda/python update.
# This list of miniconda installer versions together with their SHA256 check sums are available:
# https://docs.conda.io/en/latest/miniconda_hashes.html
ENV PYTHON_VERSION py39
ENV CONDA_VERSION 4.12.0
ENV MINICONDA_VERSION ${PYTHON_VERSION}_${CONDA_VERSION}
# Always activate /etc/profile, otherwise conda won't work.
ENV BASH_ENV /etc/profile
USER root
# Fix locales.
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
# Install debian packages.
# Note: prefix all 'apt-get install' lines with 'apt-get update' to prevent failures in partial rebuilds
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
tzdata
# Install required ubuntu packages.
# The libpq-dev is needed for arm64 to pypi build psycopg2-binary in aiida-core
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
bzip2 \
erlang \
git \
gir1.2-gtk-3.0 \
gnupg \
graphviz \
locales \
less \
psmisc \
rsync \
ssh \
unzip \
vim \
wget \
zip \
libpq-dev \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean all
# Install conda.
RUN cd /tmp && \
if [ "$TARGETARCH" = "amd64" ]; then \
echo "x86_64" && \
export MINICONDA_ARCH=x86_64 && \
export MINICONDA_SHA256=78f39f9bae971ec1ae7969f0516017f2413f17796670f7040725dd83fcff5689; \
elif [ "$TARGETARCH" = "arm64" ]; then \
echo "aarch64" && \
export MINICONDA_ARCH=aarch64 && \
export MINICONDA_SHA256=5f4f865812101fdc747cea5b820806f678bb50fe0a61f19dc8aa369c52c4e513; \
else \
echo "Unknown architecture: ${TARGETARCH}."; \
fi && \
wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-${MINICONDA_VERSION}-Linux-${MINICONDA_ARCH}.sh && \
echo "${MINICONDA_SHA256} *Miniconda3-${MINICONDA_VERSION}-Linux-${MINICONDA_ARCH}.sh" | sha256sum -c - && \
/bin/bash Miniconda3-${MINICONDA_VERSION}-Linux-${MINICONDA_ARCH}.sh -f -b -p $CONDA_DIR && \
rm Miniconda3-${MINICONDA_VERSION}-Linux-${MINICONDA_ARCH}.sh && \
echo "conda ${CONDA_VERSION}" >> $CONDA_DIR/conda-meta/pinned && \
conda config --system --prepend channels conda-forge && \
conda config --system --set auto_update_conda false && \
conda config --system --set show_channel_urls true && \
conda list python | grep '^python ' | tr -s ' ' | cut -d '.' -f 1,2 | sed 's/$/.*/' >> $CONDA_DIR/conda-meta/pinned && \
conda install --quiet --yes conda && \
conda install --quiet --yes pip && \
conda update --all --quiet --yes && \
conda clean --all -f -y
# Install PostgreSQL in a dedicated conda environment.
RUN conda create -c conda-forge -n pgsql postgresql=10 && conda clean --all -f -y
# Below is a solution to a strange bug with PGSQL=10
# Taken from https://github.com/tethysplatform/tethys/issues/667.
# This bug is not present for PGSQL=14. So as soon as we migrate, the line below can be removed.
RUN cp /usr/share/zoneinfo /opt/conda/envs/pgsql/share/ -R
# Install RabbitMQ in a dedicated conda environment.
# If the architecture is arm64, we install the default version of rabbitmq provided by Ubuntu.
RUN if [ "$TARGETARCH" = "amd64" ]; then \
conda create -c conda-forge -n rmq rabbitmq-server=3.8.14 && conda clean --all -f -y; \
elif [ "$TARGETARCH" = "arm64" ]; then \
apt-get update && apt-get install -y --no-install-recommends \
rabbitmq-server && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean all; \
else \
echo "Unknown architecture: ${TARGETARCH}."; \
fi
# Copy the script load-singlesshagent.sh to /usr/local/bin.
COPY bin/load-singlesshagent.sh /usr/local/bin/load-singlesshagent.sh
# Create system user.
COPY my_init.d/create-system-user.sh /etc/my_init.d/10_create-system-user.sh
# Launch rabbitmq server
COPY opt/start-rabbitmq-${TARGETARCH}.sh /opt/start-rabbitmq.sh
COPY my_init.d/start-rabbitmq.sh /etc/my_init.d/20_start-rabbitmq.sh
# Launch postgres server.
COPY opt/start-postgres.sh /opt/start-postgres.sh
COPY my_init.d/start-postgres.sh /etc/my_init.d/30_start-postgres.sh
# Check if init script is finished.
COPY my_init.d/finalize_init.sh /etc/my_init.d/99_finalize_init.sh
# Add wait-for-services script.
COPY bin/wait-for-services /usr/local/bin/wait-for-services
# Enable prompt color in the skeleton .bashrc before creating the default ${SYSTEM_USER}.
RUN sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashrc
# Always activate conda.
COPY profile.d/activate_conda.sh /etc/profile.d/
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]