From ac82d2dab055c473b99a01ad551c7bbe9a2b49e2 Mon Sep 17 00:00:00 2001 From: asonix Date: Sun, 7 Jun 2020 20:16:18 -0500 Subject: [PATCH] Version v0.1.0-r5 --- docker/dev/Dockerfile.arm32v7 | 68 ++++++++++++++++++++++++++++++++++ docker/dev/deploy.sh | 31 ++++++++++------ docker/prod/docker-compose.yml | 2 +- 3 files changed, 89 insertions(+), 12 deletions(-) create mode 100644 docker/dev/Dockerfile.arm32v7 diff --git a/docker/dev/Dockerfile.arm32v7 b/docker/dev/Dockerfile.arm32v7 new file mode 100644 index 00000000..305fcc08 --- /dev/null +++ b/docker/dev/Dockerfile.arm32v7 @@ -0,0 +1,68 @@ +FROM rustembedded/cross:arm-unknown-linux-musleabihf AS builder + +ARG UID=991 +ARG GID=991 + +ARG TOOLCHAIN=stable +ARG TARGET=arm-unknown-linux-musleabihf +ARG TOOL=arm-linux-musleabihf + +ARG REPOSITORY=https://git.asonix.dog/asonix/pict-rs +ARG TAG=master +ARG BINARY=pict-rs + +RUN \ + apt-get update && \ + apt-get upgrade -y + +RUN \ + addgroup --gid "${GID}" build && \ + adduser \ + --disabled-password \ + --gecos "" \ + --ingroup build \ + --uid "${UID}" \ + --home /opt/build \ + build + +ADD https://sh.rustup.rs /opt/build/rustup.sh + +RUN \ + chown -R build:build /opt/build + +USER build +WORKDIR /opt/build + +ENV PATH=/opt/build/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +RUN \ + chmod +x rustup.sh && \ + ./rustup.sh --default-toolchain $TOOLCHAIN --profile minimal -y && \ + rustup target add $TARGET + +RUN \ + git clone -b $TAG $REPOSITORY repo + +WORKDIR /opt/build/repo + +RUN \ + cargo build --release --target $TARGET && \ + $TOOL-strip target/$TARGET/release/$BINARY + +FROM arm32v7/alpine:3.11 + +ARG UID=991 +ARG GID=991 +ARG BINARY=pict-rs + +COPY --from=builder /opt/build/repo/target/arm-unknown-linux-musleabihf/release/$BINARY /usr/bin/$BINARY + +RUN \ + apk add tini && \ + addgroup -g $GID pictrs && \ + adduser -D -G pictrs -g "" -h /opt/pictrs pictrs + +WORKDIR /opt/pictrs +USER pictrs +ENTRYPOINT ["/sbin/tini", "--"] +CMD ["/usr/bin/pict-rs"] diff --git a/docker/dev/deploy.sh b/docker/dev/deploy.sh index f7ee44ef..39881c71 100755 --- a/docker/dev/deploy.sh +++ b/docker/dev/deploy.sh @@ -18,6 +18,23 @@ function print_help() { echo " tag: The git tag to be applied to the repository and docker build" } +function build_image() { + tag=$1 + arch=$2 + + docker build \ + --pull \ + --no-cache \ + --build-arg TAG=$tag \ + -t asonix/pictrs:$arch-$tag \ + -t asonix/pictrs:$arch-latest \ + -f Dockerfile.$arch \ + . + + docker push asonix/pictrs:$arch-$tag + docker push asonix/pictrs:$arch-latest +} + # Creating the new tag new_tag="$1" @@ -52,17 +69,9 @@ docker tag dev_pictrs:latest asonix/pictrs:x64-latest docker push asonix/pictrs:x64-$new_tag docker push asonix/pictrs:x64-latest -# Build for arm64v8 -docker build \ - --pull \ - --no-cache \ - --build-arg TAG=$new_tag \ - -t asonix/pictrs:arm64v8-$new_tag \ - -t asonix/pictrs:arm64v8-latest \ - -f Dockerfile.arm64v8 \ - . -docker push asonix/pictrs:arm64v8-$new_tag -docker push asonix/pictrs:arm64v8-latest +# Build for arm64v8 and arm32v7 +build_image $new_tag arm64v8 +build_image $new_tag arm32v7 # Build for other archs # TODO diff --git a/docker/prod/docker-compose.yml b/docker/prod/docker-compose.yml index 69fe2900..c18a9d4e 100644 --- a/docker/prod/docker-compose.yml +++ b/docker/prod/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.3' services: pictrs: - image: asonix/pictrs:v0.1.0-r4 + image: asonix/pictrs:v0.1.0-r5 user: root ports: - "127.0.0.1:8080:8080"