Docker: use variables instead of hard-coded stuff

WHEELHOUSE: since we're defining the variable we might as well use it.
DOCKER_IMAGE_NAME: introduced to prevent duplications of the name, and to
    add a little confirmation message when the script is done.
This commit is contained in:
2019-05-10 14:46:59 +02:00
parent ba69dd46a0
commit 3d567ff6f8

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
DOCKER_IMAGE_NAME=armadillica/pillar_wheelbuilder
set -e set -e
# macOS does not support readlink -f, so we use greadlink instead # macOS does not support readlink -f, so we use greadlink instead
@@ -21,14 +23,15 @@ fi
echo "Wheelhouse is $WHEELHOUSE" echo "Wheelhouse is $WHEELHOUSE"
mkdir -p "$WHEELHOUSE" mkdir -p "$WHEELHOUSE"
rm -f "$WHEELHOUSE"/*
docker build -t armadillica/pillar_wheelbuilder:latest . docker build -t $DOCKER_IMAGE_NAME:latest .
GID=$(id -g) GID=$(id -g)
docker run --rm -i \ docker run --rm -i \
-v "$WHEELHOUSE:/data/wheelhouse" \ -v "$WHEELHOUSE:/data/wheelhouse" \
-v "$TOPDEVDIR:/data/topdev" \ -v "$TOPDEVDIR:/data/topdev" \
armadillica/pillar_wheelbuilder <<EOT $DOCKER_IMAGE_NAME <<EOT
set -e set -e
pip3 install wheel poetry pip3 install wheel poetry
@@ -39,15 +42,13 @@ poetry install --no-dev
# Apparently pip doesn't like projects without setup.py, so it think we have 'pillar-svnman' as # Apparently pip doesn't like projects without setup.py, so it think we have 'pillar-svnman' as
# requirement (because that's the name of the directory). We have to grep that out. # requirement (because that's the name of the directory). We have to grep that out.
poetry run pip3 freeze | grep -v '\(pillar\)\|\(^-[ef] \)' > /data/wheelhouse/requirements.txt poetry run pip3 freeze | grep -v '\(pillar\)\|\(^-[ef] \)' > \$WHEELHOUSE/requirements.txt
pip3 wheel --wheel-dir=/data/wheelhouse -r /data/wheelhouse/requirements.txt pip3 wheel --wheel-dir=\$WHEELHOUSE -r \$WHEELHOUSE/requirements.txt
chown -R $UID:$GID /data/wheelhouse chown -R $UID:$GID \$WHEELHOUSE
# Install the dependencies so that we can get a full freeze.
# pip3 install --no-index --find-links=/data/wheelhouse -r /data/wheelhouse/requirements.txt
# pip3 freeze | grep -v '^-[ef] ' > /data/wheelhouse/requirements.txt
EOT EOT
# Remove our own projects, they shouldn't be installed as wheel (for now). # Remove our own projects, they shouldn't be installed as wheel (for now).
rm -f $WHEELHOUSE/{attract,flamenco,pillar,pillarsdk}*.whl rm -f $WHEELHOUSE/{attract,flamenco,pillar,pillarsdk}*.whl
echo "Build of $DOCKER_IMAGE_NAME:latest is done."