Remove previous deploy logic
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d163a3cf79
commit
39e2344fb2
|
@ -1,74 +0,0 @@
|
||||||
FROM rustembedded/cross:x86_64-unknown-linux-musl AS x86_64-builder
|
|
||||||
|
|
||||||
ARG UID=991
|
|
||||||
ARG GID=991
|
|
||||||
|
|
||||||
ENV TOOLCHAIN=stable
|
|
||||||
ENV TARGET=x86_64-unknown-linux-musl
|
|
||||||
ENV TOOL=x86_64-linux-musl
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
FROM x86_64-builder as builder
|
|
||||||
|
|
||||||
ARG TAG=main
|
|
||||||
ARG REPOSITORY=https://git.asonix.dog/asonix/warriors-names
|
|
||||||
ARG BINARY=warriors-names
|
|
||||||
|
|
||||||
RUN \
|
|
||||||
git clone -b $TAG $REPOSITORY repo
|
|
||||||
|
|
||||||
WORKDIR /opt/build/repo
|
|
||||||
|
|
||||||
RUN \
|
|
||||||
cargo build --release --target $TARGET && \
|
|
||||||
$TOOL-strip target/$TARGET/release/$BINARY
|
|
||||||
|
|
||||||
FROM amd64/alpine:3.11
|
|
||||||
|
|
||||||
ARG UID=991
|
|
||||||
ARG GID=991
|
|
||||||
ARG BINARY=warriors-names
|
|
||||||
|
|
||||||
COPY --from=builder /opt/build/repo/target/x86_64-unknown-linux-musl/release/$BINARY /usr/bin/$BINARY
|
|
||||||
|
|
||||||
RUN \
|
|
||||||
apk add tini && \
|
|
||||||
addgroup -g $GID warriors && \
|
|
||||||
adduser -D -G warriors -u $UID -g "" -h /opt/warriors warriors
|
|
||||||
|
|
||||||
RUN \
|
|
||||||
chown -R warriors:warriors /mnt
|
|
||||||
|
|
||||||
VOLUME /mnt
|
|
||||||
WORKDIR /opt/warriors
|
|
||||||
USER warriors
|
|
||||||
ENTRYPOINT ["/sbin/tini", "--"]
|
|
||||||
CMD ["/usr/bin/warriors-names"]
|
|
|
@ -1,74 +0,0 @@
|
||||||
FROM rustembedded/cross:arm-unknown-linux-musleabihf AS arm32v7-builder
|
|
||||||
|
|
||||||
ARG UID=991
|
|
||||||
ARG GID=991
|
|
||||||
|
|
||||||
ENV TOOLCHAIN=stable
|
|
||||||
ENV TARGET=arm-unknown-linux-musleabihf
|
|
||||||
ENV TOOL=arm-linux-musleabihf
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
FROM arm32v7-builder as builder
|
|
||||||
|
|
||||||
ARG TAG=main
|
|
||||||
ARG REPOSITORY=https://git.asonix.dog/asonix/warriors-names
|
|
||||||
ARG BINARY=warriors-names
|
|
||||||
|
|
||||||
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=warriors-names
|
|
||||||
|
|
||||||
COPY --from=builder /opt/build/repo/target/arm-unknown-linux-musleabihf/release/$BINARY /usr/bin/$BINARY
|
|
||||||
|
|
||||||
RUN \
|
|
||||||
apk add tini && \
|
|
||||||
addgroup -g $GID warriors && \
|
|
||||||
adduser -D -G warriors -u $UID -g "" -h /opt/warriors warriors
|
|
||||||
|
|
||||||
RUN \
|
|
||||||
chown -R warriors:warriors /mnt
|
|
||||||
|
|
||||||
VOLUME /mnt
|
|
||||||
WORKDIR /opt/warriors
|
|
||||||
USER warriors
|
|
||||||
ENTRYPOINT ["/sbin/tini", "--"]
|
|
||||||
CMD ["/usr/bin/warriors-names"]
|
|
|
@ -1,74 +0,0 @@
|
||||||
FROM rustembedded/cross:aarch64-unknown-linux-musl AS aarch64-builder
|
|
||||||
|
|
||||||
ARG UID=991
|
|
||||||
ARG GID=991
|
|
||||||
|
|
||||||
ENV TOOLCHAIN=stable
|
|
||||||
ENV TARGET=aarch64-unknown-linux-musl
|
|
||||||
ENV TOOL=aarch64-linux-musl
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
FROM aarch64-builder as builder
|
|
||||||
|
|
||||||
ARG TAG=main
|
|
||||||
ARG REPOSITORY=https://git.asonix.dog/asonix/warriors-names
|
|
||||||
ARG BINARY=warriors-names
|
|
||||||
|
|
||||||
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
|
|
||||||
ARG BINARY=warriors-names
|
|
||||||
|
|
||||||
COPY --from=builder /opt/build/repo/target/aarch64-unknown-linux-musl/release/$BINARY /usr/bin/$BINARY
|
|
||||||
|
|
||||||
RUN \
|
|
||||||
apk add tini && \
|
|
||||||
addgroup -g $GID warriors && \
|
|
||||||
adduser -D -G warriors -u $UID -g "" -h /opt/warriors warriors
|
|
||||||
|
|
||||||
RUN \
|
|
||||||
chown -R warriors:warriors /mnt
|
|
||||||
|
|
||||||
VOLUME /mnt
|
|
||||||
WORKDIR /opt/warriors
|
|
||||||
USER warriors
|
|
||||||
ENTRYPOINT ["/sbin/tini", "--"]
|
|
||||||
CMD ["/usr/bin/warriors-names"]
|
|
|
@ -1,76 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
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"
|
|
||||||
echo " branch: The git branch to use for tagging and publishing"
|
|
||||||
}
|
|
||||||
|
|
||||||
function build_image() {
|
|
||||||
tag=$1
|
|
||||||
arch=$2
|
|
||||||
|
|
||||||
docker build \
|
|
||||||
--pull \
|
|
||||||
--build-arg TAG=$tag \
|
|
||||||
-t asonix/warriors-names:$arch-$tag \
|
|
||||||
-t asonix/warriors-names:$arch-latest \
|
|
||||||
-f Dockerfile.$arch \
|
|
||||||
.
|
|
||||||
|
|
||||||
docker push asonix/warriors-names:$arch-$tag
|
|
||||||
docker push asonix/warriors-names:$arch-latest
|
|
||||||
}
|
|
||||||
|
|
||||||
# Creating the new tag
|
|
||||||
new_tag="$1"
|
|
||||||
branch="$2"
|
|
||||||
|
|
||||||
require "$new_tag" "tag"
|
|
||||||
require "$branch" "branch"
|
|
||||||
|
|
||||||
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 $branch
|
|
||||||
|
|
||||||
# Changing the docker-compose prod
|
|
||||||
sed -i "s/asonix\/warriors-names:.*/asonix\/warriors-names:$new_tag/" docker-compose.yml
|
|
||||||
git add ../prod/docker-compose.yml
|
|
||||||
|
|
||||||
# The commit
|
|
||||||
git commit -m"Version $new_tag"
|
|
||||||
git tag $new_tag
|
|
||||||
|
|
||||||
# Push
|
|
||||||
git push origin $new_tag
|
|
||||||
git push
|
|
||||||
|
|
||||||
# Build for arm64v8, arm32v7, and amd64
|
|
||||||
build_image $new_tag arm64v8
|
|
||||||
build_image $new_tag arm32v7
|
|
||||||
build_image $new_tag amd64
|
|
||||||
|
|
||||||
# Build for other archs
|
|
||||||
# TODO
|
|
||||||
|
|
||||||
./manifest.sh asonix/warriors-names $new_tag
|
|
||||||
./manifest.sh asonix/warriors-names latest
|
|
|
@ -2,7 +2,7 @@ version: '3.3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
warriors-names:
|
warriors-names:
|
||||||
image: asonix/warriors-names:v0.2.0
|
image: asonix/warriors-names:v0.2.1
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- ./volumes/warriors-names:/opt/warriors
|
- ./volumes/warriors-names:/opt/warriors
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
function require() {
|
|
||||||
if [ "$1" = "" ]; then
|
|
||||||
echo "input '$2' required"
|
|
||||||
print_help
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function print_help() {
|
|
||||||
echo "deploy.sh"
|
|
||||||
echo ""
|
|
||||||
echo "Usage:"
|
|
||||||
echo " manifest.sh [repository] [tag]"
|
|
||||||
echo ""
|
|
||||||
echo "Args:"
|
|
||||||
echo " repository: The docker repository hosting the images"
|
|
||||||
echo " tag: The git tag to be applied to the image manifest"
|
|
||||||
}
|
|
||||||
|
|
||||||
repo=$1
|
|
||||||
new_tag=$2
|
|
||||||
|
|
||||||
require "$repo" "repository"
|
|
||||||
require "$new_tag" "tag"
|
|
||||||
|
|
||||||
set -xe
|
|
||||||
|
|
||||||
docker manifest create $repo:$new_tag \
|
|
||||||
-a $repo:arm64v8-$new_tag \
|
|
||||||
-a $repo:arm32v7-$new_tag \
|
|
||||||
-a $repo:amd64-$new_tag
|
|
||||||
|
|
||||||
docker manifest annotate $repo:$new_tag \
|
|
||||||
$repo:arm64v8-$new_tag --os linux --arch arm64 --variant v8
|
|
||||||
|
|
||||||
docker manifest annotate $repo:$new_tag \
|
|
||||||
$repo:arm32v7-$new_tag --os linux --arch arm --variant v7
|
|
||||||
|
|
||||||
docker manifest annotate $repo:$new_tag \
|
|
||||||
$repo:amd64-$new_tag --os linux --arch amd64
|
|
||||||
|
|
||||||
docker manifest push $repo:$new_tag --purge
|
|
Loading…
Reference in a new issue