Page MenuHomeSoftware Heritage

docker/build_image.sh: Add script to build/ push to docker registry
AbandonedPublic

Authored by ardumont on Mar 29 2022, 4:25 PM.

Details

Summary

Related to T4105

Test Plan

Executed to only build and not push for now (with set -x):

PUBLISH=no ./build_image.sh
++ date +%Y%m%d
+ builddate=20220329
++ date +%H%M%S
+ buildtime=161951
+ builddatetime=20220329-161951
++ docker info
++ grep Username
++ awk '{print $2}'
+ username=ardumont
+ img=softwareheritage/maven-index-exporter
+ docker build --file Dockerfile --tag softwareheritage/maven-index-exporter:20220329-161951 .
Sending build context to Docker daemon  34.82kB
Step 1/8 : FROM adoptopenjdk/openjdk11:debian-jre
 ---> e4102b823981
Step 2/8 : ADD https://github.com/javasoze/clue/releases/download/release-6.2.0-1.0.0/clue-6.2.0-1.0.0.jar /opt/
Downloading [==================================================>]     18MB/18MB

 ---> Using cache
 ---> 4740fa64ca63
Step 3/8 : ADD https://repo1.maven.org/maven2/org/apache/maven/indexer/indexer-cli/6.0.0/indexer-cli-6.0.0.jar /opt/
Downloading [==================================================>]  14.91MB/14.91MB

 ---> Using cache
 ---> 12e65362e94e
Step 4/8 : COPY extract_indexes.sh /opt/
 ---> Using cache
 ---> c9694e5a268a
Step 5/8 : WORKDIR /work/
 ---> Using cache
 ---> 525c41be817b
Step 6/8 : RUN ls /opt/
 ---> Using cache
 ---> 91b3eb5e16cc
Step 7/8 : RUN ls -R /work/
 ---> Using cache
 ---> 335f0f195859
Step 8/8 : CMD ["sh", "/opt/extract_indexes.sh"]
 ---> Using cache
 ---> aa1d2756a484
Successfully built aa1d2756a484
Successfully tagged softwareheritage/maven-index-exporter:20220329-161951
+ docker tag softwareheritage/maven-index-exporter:20220329-161951 softwareheritage/maven-index-exporter:20220329
+ docker tag softwareheritage/maven-index-exporter:20220329 softwareheritage/maven-index-exporter:latest
+ [[ -n ardumont ]]
+ [[ no = \y\e\s ]]
+ echo 'Done creating images.'
Done creating images.

Diff Detail

Repository
rDLSMAVEXP maven-index-exporter
Branch
main
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 27934
Build 43742: arc lint + arc unit

Event Timeline

vsellier added a subscriber: vsellier.
vsellier added inline comments.
docker/build_image.sh
5

Doesn't seems to match the real behavior of the script

(not pushing by default as implemented seems to be a better default ;))

28

Do we really need all these images on docker hub?

The pushed images should be related to a tag in the git repository to know what the image contains or we will never know which version is running on the servers .

We should build the latest by default and support a way to override the tag name to something specific when needed

This revision now requires changes to proceed.Mar 29 2022, 5:08 PM
docker/build_image.sh
5

right, better formulation:

# Use: ./build_image.sh: Build the image. If the user is logged in and PUBLISH variable
# environment is set to yes, the image is also pushed in docker repository.

sounds good?

28

no idea, i just copied everything from there.
Agreed that the a git tag sounds better!

Will see what i can about it.
Thanks.

docker/build_image.sh
15

Another thought, the --pull option allows to refresh the base image if a new version is available.

douardda added inline comments.
docker/build_image.sh
28

Do we really need all these images on docker hub?

The pushed images should be related to a tag in the git repository to know what the image contains or we will never know which version is running on the servers .

For swh-docker, the git repository tells you nothing about the content of the image, which content will only depend on the date it has been build (since we do not have pinned versions anywhere).

I would have loved to be able to store the list of swh package version installed in an image as a set of labels on that image, but I failed to find a simple method to do so (aka add labels from the dockerfile which values are the result of the execution of a command in the dockerfile). There is an issue on the similar idea on gh for years (which I cannot find right now), but it has never been implemented (might be tricky to do so).

For this image, it makes more sense since it's just a matter of installing a few jar (if I get this right).

We should build the latest by default and support a way to override the tag name to something specific when needed

What "Latest" refers to actually here?