mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-12-22 19:31:35 +00:00
Add arm files, fancify deploy.sh
This commit is contained in:
parent
b4f4a6258e
commit
1b8ea71650
2 changed files with 120 additions and 13 deletions
67
docker/dev/Dockerfile.arm64v8
Normal file
67
docker/dev/Dockerfile.arm64v8
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
FROM rustembedded/cross:aarch64-unknown-linux-musl AS builder
|
||||||
|
|
||||||
|
ARG UID=991
|
||||||
|
ARG GID=991
|
||||||
|
|
||||||
|
ARG TOOLCHAIN=stable
|
||||||
|
ARG TARGET=aarch64-unknown-linux-musl
|
||||||
|
ARG TOOL=aarch64-linux-musl
|
||||||
|
|
||||||
|
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 arm64v8/alpine:3.11
|
||||||
|
|
||||||
|
ARG UID=991
|
||||||
|
ARG GID=991
|
||||||
|
|
||||||
|
COPY --from=builder /opt/build/repo/target/aarch64-unknown-linux-musl/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"]
|
66
docker/dev/deploy.sh
Normal file → Executable file
66
docker/dev/deploy.sh
Normal file → Executable file
|
@ -1,10 +1,38 @@
|
||||||
# To deploy, run ./deploy [tag]
|
#!/usr/bin/env bash
|
||||||
#!/bin/sh
|
|
||||||
git checkout master
|
function require() {
|
||||||
|
if [ "$1" = "" ]; then
|
||||||
|
echo "input '$2' required"
|
||||||
|
print_help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function print_help() {
|
||||||
|
echo "deploy.sh"
|
||||||
|
echo ""
|
||||||
|
echo "Usage:"
|
||||||
|
echo " deploy.sh [tag]"
|
||||||
|
echo ""
|
||||||
|
echo "Args:"
|
||||||
|
echo " tag: The git tag to be applied to the repository and docker build"
|
||||||
|
}
|
||||||
|
|
||||||
# Creating the new tag
|
# Creating the new tag
|
||||||
new_tag="$1"
|
new_tag="$1"
|
||||||
|
|
||||||
|
require "$new_tag" "tag"
|
||||||
|
|
||||||
|
if ! docker run --rm -it arm64v8/alpine:3.11 /bin/sh -c 'echo "docker is configured correctly"'
|
||||||
|
then
|
||||||
|
echo "docker is not configured to run on qemu-emulated architectures, fixing will require sudo"
|
||||||
|
sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -xe
|
||||||
|
|
||||||
|
git checkout master
|
||||||
|
|
||||||
# Changing the docker-compose prod
|
# Changing the docker-compose prod
|
||||||
sed -i "s/asonix\/pictrs:.*/asonix\/pictrs:$new_tag/" ../prod/docker-compose.yml
|
sed -i "s/asonix\/pictrs:.*/asonix\/pictrs:$new_tag/" ../prod/docker-compose.yml
|
||||||
git add ../prod/docker-compose.yml
|
git add ../prod/docker-compose.yml
|
||||||
|
@ -13,16 +41,28 @@ git add ../prod/docker-compose.yml
|
||||||
git commit -m"Version $new_tag"
|
git commit -m"Version $new_tag"
|
||||||
git tag $new_tag
|
git tag $new_tag
|
||||||
|
|
||||||
# Rebuilding docker
|
|
||||||
docker-compose build
|
|
||||||
docker tag dev_pictrs:latest asonix/pictrs:x64-$new_tag
|
|
||||||
docker push asonix/pictrs:x64-$new_tag
|
|
||||||
|
|
||||||
# Build for Raspberry Pi / other archs
|
|
||||||
# TODO
|
|
||||||
|
|
||||||
docker manifest push asonix/pictrs:$new_tag
|
|
||||||
|
|
||||||
# Push
|
# Push
|
||||||
git push origin $new_tag
|
git push origin $new_tag
|
||||||
git push
|
git push
|
||||||
|
|
||||||
|
# Rebuilding docker
|
||||||
|
docker-compose build
|
||||||
|
docker tag dev_pictrs:latest asonix/pictrs:x64-$new_tag
|
||||||
|
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 \
|
||||||
|
.
|
||||||
|
# Build for other archs
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
# TODO: docker manifest
|
||||||
|
# docker manifest push asonix/pictrs:$new_tag
|
||||||
|
|
Loading…
Reference in a new issue