1
0
mirror of https://github.com/mveril/qp-demo synced 2024-12-23 04:43:51 +01:00
qp-demo/Dockerfile

77 lines
3.1 KiB
Docker
Raw Normal View History

2019-11-06 14:40:50 +01:00
# For help about how Dockerfiles work, see https://docs.docker.com/engine/reference/builder
2021-05-04 11:08:08 +02:00
ARG UBUNTU_VERSION=20.04
FROM ubuntu:${UBUNTU_VERSION} AS builder
2021-04-30 13:05:57 +02:00
# Build argument (can be changed at build time
# This argument define timezone for tzdata requierd by qp_run
ARG tz=Etc/UTC
# Install all requierd packages
2021-05-04 12:29:00 +02:00
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
2021-04-30 13:05:57 +02:00
# Git for download quantum package
git \
# All necessary packages to compile and run quantum package
2021-05-04 12:29:00 +02:00
curl wget python gfortran gcc g++ build-essential unzip liblapack-dev pkg-config autoconf zlib1g zlib1g-dev libgmp-dev
2021-04-30 13:05:57 +02:00
# Add user and switch to this user
RUN adduser --disabled-password --gecos '' builder
USER builder
# I don't know why but the USER environment variable is not set so I set it because it's requested for ninja
ENV USER=builder
# Go to home
WORKDIR /home/builder
# Download quantum package
RUN git clone --depth 1 --branch 2.1.2 https://github.com/QuantumPackage/qp2
# Go to quantum package
WORKDIR /home/builder/qp2
# Configure
RUN ./configure -i all -c config/gfortran_avx.cfg
# source don't work with /bin/sh (used by the run command so I use bash)
# Compile the code to a static build
2021-05-04 11:16:03 +02:00
RUN ["/bin/bash", "-c", "source quantum_package.rc ; qp export_as_tgz"]
2021-04-30 13:05:57 +02:00
# Used to unpack QP2
2021-05-04 11:10:27 +02:00
FROM busybox AS unpack
WORKDIR /tmp
COPY --from=builder /home/builder/qp2/quantum_package_static.tar.gz .
RUN tar -xf quantum_package_static.tar.gz
2021-04-30 13:05:57 +02:00
2019-11-06 14:40:50 +01:00
# This image is based from Ubuntu LTS
2021-05-04 11:08:08 +02:00
FROM ubuntu:${UBUNTU_VERSION}
2021-05-04 14:44:50 +02:00
LABEL version="2.1.2" \
2019-11-06 14:40:50 +01:00
maintainer.name="Mickaël Véril" \
quantum_package.author.name="Anthony Scemama" \
quantum_package.url="https://quantumpackage.github.io/qp2" \
quantum_package.repo="https://github.com/QuantumPackage/qp2" \
2021-04-29 13:51:51 +02:00
quantum_package.demo.repo="https://github.com/mveril/qp-demo" \
2019-11-06 14:40:50 +01:00
laboratory.name="Laboratoire de Chimie et Physique Quantique (LCPQ)" \
laboratory.url="http://www.lcpq.ups-tlse.fr/"
2020-06-11 10:01:01 +02:00
# Build argument (can be changed at build time
2019-11-06 14:40:50 +01:00
# This argument define the user name
ARG user=user
# This argument define timezone for tzdata requierd by qp_run
ARG tz=Etc/UTC
# Unminimize and install all requierd packages
RUN yes | unminimize && apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
2021-05-28 17:54:19 +02:00
python htop vim emacs-nox screen tmux less wget curl tzdata man manpages-posix lsb-release \
&& rm -rf /var/lib/apt/lists/*
2019-11-06 14:40:50 +01:00
# Reconfigure tzdata with the good timezone
RUN echo $tz > /etc/timezone && rm -rf /etc/localtime && echo "set mouse=" > ~/.vimrc
RUN dpkg-reconfigure -f noninteractive tzdata
2021-04-30 13:05:57 +02:00
# Add user and switch to this user
2019-11-06 14:40:50 +01:00
RUN adduser --disabled-password --gecos '' $user
USER $user
# I don't know why but the USER environment variable is not set so I set it because it's requested for ninja
ENV USER=$user
# Go to home
WORKDIR /home/$user
2021-04-30 13:05:57 +02:00
# Copy examples
2021-05-04 12:58:04 +02:00
COPY --chown=$user examples examples
# Copy unpacked QP2 static
2021-05-04 12:58:04 +02:00
COPY --from=unpack --chown=$user /tmp/quantum_package_static qp2
# Prepare tmux and screen to use QPSH
2019-11-06 14:40:50 +01:00
RUN echo "set -g default-command /home/$user/qp2/bin/qpsh" >> .tmux.conf
RUN echo "shell \"/home/$user/qp2/bin/qpsh\"" >> .screenrc
# start a qp shell when run
CMD ["./qp2/bin/qpsh"]