Commit b9662b38 authored by Alexandre Beelen's avatar Alexandre Beelen

New multi targets dockerfile

parent ea35574b
# Changelog
## [latest]
### Added
- One Dockerfile for two targets, with and without piic
- check_new_release.py gildas_release.py to check for new gildas releases and give corresponding docker command to build images
## [nov19a]
- New gildas release
### BUG
- Do not have a corresponding PIIC package
## [oct19a]
### Added
- PIIC and the gagpiic & gaggildas related commands
......@@ -5,9 +5,8 @@ RUN apt-get -y update && apt-get install -y \
libfftw3-3 \
libcfitsio5 \
libforms2 \
python \
libpython2.7 \
python-numpy \
python3 \
python3-numpy \
libgtk2.0
FROM gildas_worker as gildas_builder
......@@ -17,7 +16,7 @@ RUN apt-get -y update && apt-get install -y \
libfftw3-dev \
libcfitsio-dev \
libforms-dev \
python-dev \
python3-dev \
libgtk2.0-dev \
gfortran \
curl
......@@ -35,23 +34,32 @@ CMD sh -c
RUN curl $GILDAS_URL/gildas-src-$release.tar.xz | tar xJ && \
bash -c "cd gildas-src-$release && GAG_SEARCH_PATH=/usr/lib/x86_64-linux-gnu source admin/gildas-env.sh -o openmp && \
make && make -j 4 install" && \
echo 'export GAG_ROOT_DIR=/gildas-exe-$release' >> /etc/bash.bashrc && \
echo 'export GAG_EXEC_SYSTEM=x86_64-debian9-gfortran-openmp' >> /etc/bash.bashrc && \
echo '. $GAG_ROOT_DIR/etc/bash_profile' >> /etc/bash.bashrc && \
rm -Rf gildas-src-$release && \
cd gildas-exe-$release && curl $GILDAS_URL/gildas-doc-$release.tar.xz | tar xJ
FROM gildas_worker
FROM gildas_worker as gildas
ARG release
ENV release=${release}
COPY --from=builder /gildas-exe-$release /gildas-exe-$release
RUN echo '# \n\
echo export GAG_ROOT_DIR=/gildas-exe-$release >> /etc/bash.bashrc \n\
echo export GAG_EXEC_SYSTEM=x86_64-debian9-gfortran-openmp >> /etc/bash.bashrc \n\
echo . $GAG_ROOT_DIR/etc/bash_profile >> /etc/bash.bashrc \n\
\n'\
>> /etc/bash.bashrc
ENTRYPOINT ["/bin/bash", "--rcfile", "/etc/bash.bashrc", "-i", "-c"]
from gildas as gildas-piic
COPY --from=builder /etc/bash.bashrc /etc/bash.bashrc
ARG PIIC_ARCHIVE
# if --build-arg ARCHIVE=1 set the url to the archive page
ENV GILDAS_URL=${PIIC_ARCHIVE:+http://www.iram.fr/~gildas/dist/archive/gildas}
# else keep the main directory
ENV GILDAS_URL=${GILDAS_URL:-http://www.iram.fr/~gildas/dist}
RUN curl $GILDAS_URL/piic-exe-$release.tar.xz | tar xJ
RUN curl $GILDAS_URL/piic-exe-$release.tar.xz | tar xJ; exit 0
RUN echo '# \n\
# Two separate gildas environement (PIIC.README)...\n\
gagpiic () {\n\
......@@ -65,4 +73,3 @@ export GAG_EXEC_SYSTEM=x86_64-debian9-gfortran-openmp\n\
. $GAG_ROOT_DIR/etc/bash_profile\n\
}\n'\
>> /etc/bash.bashrc
ENTRYPOINT ["/bin/bash", "--rcfile", "/etc/bash.bashrc", "-i", "-c"]
# Build
## Two stage build
(Obsolete, see commit older than e86aabb9c4a207889685875f345f1a0b8b0cbdbf)
## One stage build
With Docker 17.05 or higher :
```bash
export release=mar18c
docker build --tag abeelen/gildas:$release --tag abeelen/gildas:latest --build-arg release=$release -f Dockerfile .
```
## PIIC
Starting with oct19a, PIIC is included in the container, with 2 possible arguments, `ARCHIVE=1` will look for gildas in the archive , while `PIIC_ARCHIVE`, will look for piic in the archive
```bash
export release=oct19a
docker build --tag abeelen/gildas:${release} --tag abeelen/gildas:latest --build-arg ARCHIVE=1 --build-arg release=$release -f Dockerfile .
```
will look for gildas oct19a in the archive, while PIIC will be downloaded from the regular directory
# Usage
To launch the gildas container, type :
......@@ -54,9 +30,11 @@ ip=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}’)
xhost + $ip
```
You can then use any of the gildas command.
Starting from the oct19a, one has to define which gildas environement to use either `gaggildas` or `gagpiic` before launching gildas command.
Starting from the oct19a, one has to define which gildas environement to use either `gaggildas` or `gagpiic` before launching gildas command. It is easier to create usefull aliases in `~/.bashrc`
It is easier to create usefull aliases in `~/.bashrc`
```bash
......@@ -67,7 +45,7 @@ alias gildas_docker='docker run -it \
--volume "/home/$USER:/home/$USER" \
--volume "/Users/$USER:/Users/$USER" \
--volume "/tmp/.X11-unix:/tmp/.X11-unix" \
abeelen/gildas:latest'
abeelen/gildas:latest-piic'
alias clic='gildas_docker "gaggildas; clic"'
alias mapping='gildas_docker "gaggildas; mapping"'
......@@ -76,4 +54,64 @@ alias piic='gildas_docker "gagpiic; piic"'
[...]
```
Alternatively if you do not need PIIC,
```bash
alias gildas_docker='docker run -it \
--hostname "gildas" --user $(id -u):$(id -g) \
--workdir="/home/$USER" --env HOME=${HOME} --env USER=${USER} --env DISPLAY=${DISPLAY} \
--volume "/etc/passwd:/etc/passwd:ro" \
--volume "/home/$USER:/home/$USER" \
--volume "/Users/$USER:/Users/$USER" \
--volume "/tmp/.X11-unix:/tmp/.X11-unix" \
abeelen/gildas:latest'
alias clic='gildas_docker clic'
alias mapping='gildas_docker mapping'
alias astro='gildas_docker astro'
[...]
```
# Build
## Two stage build
(Obsolete, see commit older than e86aabb9c4a207889685875f345f1a0b8b0cbdbf)
## One stage build
With Docker 17.05 or higher :
```bash
export release=mar18c
docker build --tag abeelen/gildas:$release --tag abeelen/gildas:latest --build-arg release=$release -f Dockerfile .
```
## PIIC
Starting with oct19a, PIIC is included in the container, with 2 possible arguments, `ARCHIVE=1` will look for gildas in the archive , while `PIIC_ARCHIVE`, will look for piic in the archive
```bash
export release=oct19a
docker build --tag abeelen/gildas:${release} --tag abeelen/gildas:latest --build-arg ARCHIVE=1 --build-arg release=$release -f Dockerfile .
```
will look for gildas oct19a in the archive, while PIIC will be downloaded from the regular directory
`Dockerfile` for this project are available at https://git.ias.u-psud.fr/abeelen/gildas
## Check available tags on dockerhub
```bash
curl -L -s 'https://registry.hub.docker.com/v1/repositories/abeelen/gildas/tags' | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}'
```
on the gildas page :
```bash
# to get the gildas release
./_gildas_release.py
# to get the piic release
./gildas_release.py --package piic
# To look in the archive directory
./gildas_release.py --archive
```
\ No newline at end of file
#!/usr/bin/env python3
import requests
import click
from bs4 import BeautifulSoup
from gildas_release import gildas_release
s = requests.Session()
r = s.get('https://registry.hub.docker.com/v1/repositories/abeelen/gildas/tags')
tags = [item['name'] for item in r.json() if item['name'] not in ['latest', 'build']]
_gildas = gildas_release('gildas')
_archived_gildas = gildas_release('gildas', archive=True)
_piic = gildas_release('piic')
_archived_piic = gildas_release('piic', archive=True)
def is_in_archive(release, piic=False):
_main = _gildas
_archive = _archived_gildas
if piic is True:
_main = _piic
_archive = _archived_piic
if release in _main:
return ''
elif release in _archive:
if piic is False:
return '--build-arg ARCHIVE=1 '
else:
return '-build-arg PIIC_ARCHIVE=1 '
else:
raise FileNotFoundError('gildas release not found in archive')
# With or without PIIC
print('# Without piic')
for release in _gildas + _archived_gildas:
if release not in tags:
print('* {} not in dockerhub'.format(release))
cmd = 'export release={}; '.format(release)
cmd += 'docker build --tag abeelen/gildas:${release} '
cmd += '--target gildas '
cmd += is_in_archive(release)
cmd += '--build-arg release=$release -f Dockerfile . '
cmd +='&& docker push abeelen/gildas:${release}'
print(cmd)
# Force with PIIC
print('# With piic')
for release in _piic + _archived_piic:
if '{}-piic'.format(release) in tags:
continue
print('* {} not in dockerhub launch :'.format(release))
cmd = 'export release={}; '.format(release)
cmd += 'docker build --tag abeelen/gildas:${release}-piic '
cmd += '--target gildas-piic '
cmd += is_in_archive(release) + is_in_archive(release, piic=True)
cmd += '--build-arg release=$release -f Dockerfile . '
cmd +='&& docker push abeelen/gildas:${release}-piic'
print(cmd)
#!/usr/bin/env python3
import requests
import click
from bs4 import BeautifulSoup
def gildas_release(package, archive=False):
uri = 'http://www.iram.fr/~gildas/dist/'
if archive:
uri = 'http://www.iram.fr/~gildas/dist/archive/gildas'
if package == 'gildas':
package = 'gildas-src'
elif package == 'piic':
package = 'piic-exe'
else:
click.echo('Unknown package !')
s = requests.Session()
r = s.get(uri)
soup = BeautifulSoup(r.text, features="lxml")
links = [link.attrs['href'] for link in soup.find_all('a') if '.tar.xz' in link.attrs['href']]
releases = [filename.split('-')[2].split('.')[0] for filename in links if filename.startswith(package)]
return releases
@click.command()
@click.option('--package', type=click.Choice(['gildas', 'piic']), default='gildas')
@click.option('--archive', is_flag=True)
def gildas_release_click(package, archive=False):
releases = gildas_release(package, archive)
click.echo(" ".join(releases))
if __name__ == '__main__':
gildas_release_click()
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