mirror of
https://git.asonix.dog/asonix/relay.git
synced 2024-12-23 03:36:30 +00:00
Add container build script
This commit is contained in:
parent
467bd860d9
commit
82d837b963
3 changed files with 81 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
/target
|
||||
/artifacts
|
||||
|
|
30
Dockerfile.arm64v8
Normal file
30
Dockerfile.arm64v8
Normal file
|
@ -0,0 +1,30 @@
|
|||
FROM arm64v8/alpine:3.11.3 AS build
|
||||
|
||||
COPY relay /relay
|
||||
|
||||
RUN \
|
||||
apk add binutils && \
|
||||
strip /relay
|
||||
|
||||
FROM arm64v8/alpine:3.11.3
|
||||
|
||||
ARG UID=991
|
||||
ARG GID=991
|
||||
|
||||
RUN \
|
||||
apk add tini && \
|
||||
echo "Etc/UTC" > /etc/localtime && \
|
||||
mkdir -p /opt/relay && \
|
||||
addgroup --gid $GID relay && \
|
||||
adduser -D -u $UID -G relay -h /opt/relay relay && \
|
||||
echo "relay:`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 24 | mkpasswd -s -m sha-256`" | chpasswd && \
|
||||
chown -R relay:relay /opt/relay
|
||||
|
||||
COPY --from=build /relay /usr/bin/relay
|
||||
|
||||
USER relay
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["/sbin/tini", "--"]
|
||||
CMD ["relay"]
|
50
build.sh
Executable file
50
build.sh
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
BUILD_DATE=$(date)
|
||||
VERSION=$1
|
||||
|
||||
function require() {
|
||||
if [ "$1" = "" ]; then
|
||||
echo "input '$2' required"
|
||||
print_help
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function print_help() {
|
||||
echo "build.sh"
|
||||
echo ""
|
||||
echo "Usage:"
|
||||
echo " build.sh [version]"
|
||||
echo ""
|
||||
echo "Args:"
|
||||
echo " version: The version of the current container"
|
||||
}
|
||||
|
||||
require "$VERSION" "version"
|
||||
|
||||
set -xe
|
||||
|
||||
# from `cargo install cross`
|
||||
cross build \
|
||||
--target aarch64-unknown-linux-musl \
|
||||
--release
|
||||
|
||||
mkdir -p artifacts
|
||||
cp ./target/aarch64-unknown-linux-musl/release/relay artifacts/relay
|
||||
|
||||
# from `sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes`
|
||||
docker build \
|
||||
--pull \
|
||||
--no-cache \
|
||||
--build-arg BUILD_DATE="${BUILD_DATE}" \
|
||||
--build-arg TAG="${TAG}" \
|
||||
-f "Dockerfile.arm64v8" \
|
||||
-t "asonix/relay:${VERSION}-arm64v8" \
|
||||
-t "asonix/relay:latest-arm64v8" \
|
||||
-t "asonix/relay:latest" \
|
||||
./artifacts
|
||||
|
||||
docker push "asonix/relay:${VERSION}-arm64v8"
|
||||
docker push "asonix/relay:latest-arm64v8"
|
||||
docker push "asonix/relay:latest"
|
Loading…
Reference in a new issue