diff --git a/Dockerfile b/Dockerfile index bbee699..e809dcb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ -FROM alpine:3.9 +FROM alpine:3.15 ARG BUILD_DATE ARG VCS_REF ARG VERSION LABEL org.label-schema.build-date=$BUILD_DATE \ - org.label-schema.name="Let's Upload That Image" \ + org.label-schema.name="Lets Upload That Image" \ org.label-schema.url="https://lut.im/" \ org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-url="https://git.framasoft.org/luc/lutim" \ @@ -12,12 +12,37 @@ LABEL org.label-schema.build-date=$BUILD_DATE \ org.label-schema.version=$VERSION \ org.label-schema.schema-version="1.0" -RUN adduser -D lutim -COPY --chown=lutim:lutim . /home/lutim +RUN adduser -D lutim \ + && addgroup lutim root + +COPY . /home/lutim +RUN chmod -R g+rwX /home/lutim WORKDIR /home/lutim -RUN /bin/sh /home/lutim/docker/build.sh +RUN apk --no-cache add perl~=5 \ + libpq~=14 \ + perl-crypt-rijndael~=1 \ + perl-io-socket-ssl~=2 \ + perl-net-ssleay~=1 \ + su-exec~=0.2 \ + shared-mime-info~=2 \ + libretls~=3 \ + imagemagick~=7 \ + imagemagick-perlmagick~=7 \ + bash~=~5 \ + && apk --no-cache add --virtual .build-deps build-base~=0.5 \ + perl-utils~=5 \ + perl-dev~=5 \ + postgresql14-dev~=14 \ + vim~=8 \ + wget~=1 \ + zlib-dev~=1 \ + && cpan notest Carton Config::FromHash \ + && carton install --without test \ + && apk del .build-deps \ + && rm -rf /var/cache/apk/* /root/.cpan* USER lutim +EXPOSE 8080 ENTRYPOINT ["/bin/sh", "/home/lutim/docker/entrypoint.sh"] \ No newline at end of file diff --git a/docker/build.sh b/docker/build.sh deleted file mode 100644 index fd1e763..0000000 --- a/docker/build.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env sh - -set -eu - -apk update -apk add perl libpq perl-crypt-rijndael perl-io-socket-ssl perl-net-ssleay su-exec shared-mime-info libressl -sh $(dirname $0)/install-dev-env.sh - -sh $(dirname $0)/install-imagemagick.sh - -cpan notest Carton Config::FromHash -carton install --without test - -# Remove dev env -apk del .build-deps -rm -rf /var/cache/apk/* /root/.cpan* \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh old mode 100644 new mode 100755 index 4fe4050..360d818 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -eu @@ -14,7 +14,7 @@ then echo "" echo "You can then install the build dependencies with this command" echo " sh ~lutim/docker/install-dev-env.sh" - + tail -f /dev/null exit 0 fi @@ -28,7 +28,7 @@ then DB_HOST=$(perl utilities/read_conf.pl pgdb/host db) DB_PORT=$(perl utilities/read_conf.pl pgdb/port 5432) fi -if [ -n "$DB_HOST" -a -n "$DB_PORT" ] +if [ -n "$DB_HOST" ] && [ -n "$DB_PORT" ] then while ! nc -vz "${DB_HOST}" "${DB_PORT}"; do echo "Waiting for database..." diff --git a/docker/install-dev-env.sh b/docker/install-dev-env.sh deleted file mode 100644 index 2f219d7..0000000 --- a/docker/install-dev-env.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env sh - -apk --update add --virtual .build-deps build-base perl-utils perl-dev postgresql-dev vim wget zlib-dev \ No newline at end of file diff --git a/docker/install-imagemagick.sh b/docker/install-imagemagick.sh deleted file mode 100644 index 5a4f73f..0000000 --- a/docker/install-imagemagick.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env sh - -# Instructions from https://imagemagick.org/script/perl-magick.php - -set -eu - -IM_VERSION=7.0.8-41 -SHA256_DIGEST=93f73a245c25194f757c075df9f2ec40010376200cc664c21646565b8690112c - -IM_DIR="ImageMagick-$IM_VERSION" -TARBALL="$IM_DIR.tar.gz" - -ORIG_DIR="$(pwd)" - -apk add libgomp libgcc libmagic \ - libjpeg libjpeg-turbo-dev \ - libpng libpng-dev \ - tiff tiff-dev \ - libwebp libwebp-dev - -mkdir -p /tmp/im-build -cd /tmp/im-build - -echo "$SHA256_DIGEST *$TARBALL" > SHA256SUM - -wget https://imagemagick.org/download/$TARBALL -O $TARBALL -sha256sum -c SHA256SUM - -tar xvf $TARBALL -cd $IM_DIR -./configure --with-perl --with-jpeg --with-png --with-tiff --with-webp -make -j$(nproc) -make install - -ldconfig /usr/local/lib -perl -MImage::Magick -le 'print Image::Magick->QuantumDepth' - -cd "$ORIG_DIR" -apk del libjpeg-turbo-dev libpng-dev tiff-dev libwebp-dev -rm -rf /tmp/im-build \ No newline at end of file