Skip to content

Commit

Permalink
1)Update Dockerfile to enable multi arch build 2)Update README with '…
Browse files Browse the repository at this point in the history
…buildx' instructions
  • Loading branch information
vlauciani committed Sep 12, 2024
1 parent 8839065 commit abe2e07
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 64 deletions.
158 changes: 94 additions & 64 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,53 @@ ENV DEBIAN_FRONTEND=noninteractive
ENV INITRD No
ENV FAKE_CHROOT 1

ARG TARGETPLATFORM

# Print ARCHITECTURE variable
RUN echo "Detected architecture: $(uname -m)"

# install packages
RUN apt-get update \
&& apt-get dist-upgrade -y --no-install-recommends \
&& apt-get install -y \
vim \
git \
telnet \
dnsutils \
wget \
curl \
default-jre \
apt-transport-https \
procps

RUN apt-get install -y \
python3-dev \
python3-pycurl \
python3-simplejson \
libcurl4-gnutls-dev \
libssl-dev \
python3 \
python3-psutil \
python3-requests \
python3-jsonschema \
python3-setuptools \
python3-dev \
build-essential \
libxml2-dev \
libxslt1-dev \
libz-dev
vim \
git \
telnet \
dnsutils \
wget \
curl \
default-jre \
apt-transport-https \
procps

RUN apt-get update \
&& apt-get install -y \
python3-dev \
python3-pycurl \
python3-simplejson \
libcurl4-gnutls-dev \
libssl-dev \
python3 \
python3-psutil \
python3-requests \
python3-jsonschema \
python3-setuptools \
python3-dev \
python3-pip \
build-essential \
libxml2-dev \
libxslt1-dev \
libz-dev

# Upgrade pip
RUN python3 -m pip install --upgrade pip

# Set .bashrc
RUN echo "" >> /root/.bashrc \
&& echo "##################################" >> /root/.bashrc \
&& echo "alias ll='ls -l --color'" >> /root/.bashrc \
&& echo "" >> /root/.bashrc \
&& echo "export LC_ALL=\"C\"" >> /root/.bashrc \
&& echo "" >> /root/.bashrc
&& echo "##################################" >> /root/.bashrc \
&& echo "alias ll='ls -l --color'" >> /root/.bashrc \
&& echo "" >> /root/.bashrc \
&& echo "export LC_ALL=\"C\"" >> /root/.bashrc \
&& echo "" >> /root/.bashrc

# Set 'root' pwd
RUN echo root:toor | chpasswd
Expand All @@ -62,9 +71,14 @@ COPY soft/qlib2.2019.365.tar.gz /opt/
RUN tar xvzf qlib2.2019.365.tar.gz \
&& rm qlib2.2019.365.tar.gz \
&& cd qlib2 \
&& cp Makefile Makefile.original \
&& sed -e 's|ROOTDIR\s=.*|ROOTDIR = /usr/local|' -e 's|LEAPSECONDS\s=.*|LEAPSECONDS = /usr/local/etc/leapseconds|' Makefile > Makefile.new \
&& mv Makefile Makefile.original \
&& mv Makefile.new Makefile \
&& ARCHITECTURE=$(uname -m) \
&& if [ "${ARCHITECTURE}" = "aarch64" ]; then \
sed -e 's|C64\s=.*|C64 = |' Makefile > Makefile.new \
&& mv Makefile.new Makefile \
fi \
&& mkdir /usr/local/share/man/man3/ \
&& mkdir /usr/local/lib64 \
&& make clean \
Expand All @@ -78,49 +92,58 @@ COPY soft/qmerge.2014.329.tar.gz /opt/
RUN tar xvzf qmerge.2014.329.tar.gz \
&& rm qmerge.2014.329.tar.gz \
&& cd qmerge \
&& cp Makefile Makefile.original \
&& sed -e 's|^QLIB2.*|QLIB2 = /usr/local/lib64/libqlib2.a|' Makefile > Makefile.new \
&& mv Makefile Makefile.original \
&& mv Makefile.new Makefile \
&& ARCHITECTURE=$(uname -m) \
&& if [ "${ARCHITECTURE}" = "aarch64" ]; then \
sed -e 's|^CC.*|CC = cc -Wall|' Makefile > Makefile.new \
&& mv Makefile.new Makefile \
fi \
&& make clean \
&& make install \
&& rm -fr /opt/qmerge

# Get and install ObsPy
# Install ObsPy
RUN pip3 install obspy

# Get and install PyRocko - https://pyrocko.org/docs/current/install/system/deb.html
WORKDIR /opt
RUN apt-get update \
&& apt-get install -y \
software-properties-common
RUN add-apt-repository "deb http://deb.obspy.org $(lsb_release -cs) main"
RUN wget --quiet -O - https://raw.githubusercontent.com/obspy/obspy/master/misc/debian/public.key | apt-key add -
make \
git \
python3-dev \
python3-setuptools
RUN apt-get update \
&& apt-get install -y \
python3-obspy

# Get and install PyRocko - https://pyrocko.org/docs/current/install/system/deb.html
WORKDIR /opt
python3-numpy \
python3-numpy-dev \
python3-scipy \
python3-matplotlib
RUN apt-get update \
&& apt-get install -y \
python3-pyqt4 \
python3-pyqt4.qtopengl
RUN apt-get update \
&& apt-get install -y \
python3-pyqt5 \
python3-pyqt5.qtopengl \
python3-pyqt5.qtsvg
RUN apt-get update \
&& apt-get install -y \
make \
git \
python3-dev \
python3-setuptools \
python3-numpy \
python3-numpy-dev \
python3-scipy \
python3-matplotlib \
python3-pyqt4 \
python3-pyqt4.qtopengl \
python3-pyqt5 \
python3-pyqt5.qtopengl \
python3-pyqt5.qtsvg \
python3-pyqt5.qtwebengine || apt-get install -y python3-pyqt5.qtwebkit
RUN apt-get install -y python3-yaml \
python3-progressbar \
python3-jinja2 \
python3-requests
COPY soft/pyrocko_v2020.10.26.tar.gz /opt/
#RUN git clone https://git.pyrocko.org/pyrocko/pyrocko.git pyrocko \
RUN tar xvzf pyrocko_v2020.10.26.tar.gz \
&& rm pyrocko_v2020.10.26.tar.gz \
python3-pyqt5.qtwebengine || apt-get install -y python3-pyqt5.qtwebkit
RUN apt-get update \
&& apt-get install -y \
python3-yaml \
python3-progressbar \
python3-jinja2
RUN apt-get update \
&& apt-get install -y \
python3-requests
COPY soft/pyrocko_v2024.01.10.tar.gz /opt/
RUN tar xvzf pyrocko_v2024.01.10.tar.gz \
&& rm pyrocko_v2024.01.10.tar.gz \
&& cd pyrocko* \
&& python3 setup.py install
WORKDIR /
Expand Down Expand Up @@ -158,5 +181,12 @@ WORKDIR /opt
RUN mkdir /opt/OUTPUT
RUN chmod -R 777 /opt/OUTPUT

#
RUN echo "BUILDPLATFORM=${BUILDPLATFORM}" > /tmp/arc
RUN echo "TARGETPLATFORM=${TARGETPLATFORM}" >> /tmp/arc
RUN echo "TARGETOS=${TARGETOS}" >> /tmp/arc
RUN echo "TARGETARCH=${TARGETARCH}" >> /tmp/arc
RUN uname -m >> /tmp/arc

# Set entrypoint
ENTRYPOINT ["./entrypoint.sh"]
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,36 @@ the line `http://webservices.ingv.it|authoritative=any|http://eidaws-internal.in
- request stations info from `http://webservices.ingv.it` adding `authoritative=any` to the request (`http://webservices.ingv.it/fdsnws/station/1/query?authoritative=any&<other_params>`
- request the waveforms to the *dataselect* node: `http://eidaws-internal.int.ingv.it/fdsnws/dataselect/1/query?<params>`

# Build multi arch docker image
Create multi-arch builder and use it:
```
docker buildx create \
--name container-builder \
--driver docker-container \
--use
```

list builders:
```
docker buildx ls
```

build multi-arch image with `container-builder` builder:
```
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t ingv/fdsnws-fetcher:latest .
```

return to `default` builder:
```
docker buildx use default
```

NOTE:
- the `build` command, build the images but do not export it on your local registry; to do that, use `--load` option BUT it works only with one `platform`. i.e: `docker buildx build --platform linux/amd64 --load -t ingv/fdsnws-fetcher:latest`
- to push the image with both architectures, use `--push` option: i.e.: ``docker buildx build --platform linux/amd64,linux/arm64 --push -t ingv/fdsnws-fetcher:latest .`

# Contribute
Thanks to your contributions!

Expand Down

0 comments on commit abe2e07

Please sign in to comment.