feat: self containerisation

Build oxker images, for x86, arm64v8, and armv6, and publish to Docker Hub
This commit is contained in:
Jack Wills
2022-09-05 22:05:24 +00:00
parent ed80a58fee
commit c2910aaef3
7 changed files with 120 additions and 48 deletions
+26
View File
@@ -0,0 +1,26 @@
<p align="center">
<img src='https://raw.githubusercontent.com/mrjackwills/oxker/main/.github/logo.svg' width='100px'/>
</p>
<p align="center">
<h1 align="center">oxker</h1>
<div align="center">
A simple tui to view & control docker containers
</div>
</p>
<p align="center">
<a href="https://raw.githubusercontent.com/mrjackwills/oxker/main/.github/screenshot_01.jpg" target='_blank' rel='noopener noreferrer'>
<img src='https://raw.githubusercontent.com/mrjackwills/oxker/main/.github/screenshot_01.jpg' width='60%'/>
</a>
</p>
## Run
Images built for `linux/amd64`, `linux/arm64v8`, and `linux/armv6`
`docker run --rm -it --volume /var/run/docker.sock:/var/run/docker.sock:ro mrjackwills/oxker:latest`
## Help
visit the<a href="https://github.com/mrjackwills/oxker" target='_blank' rel='noopener noreferrer'> Github repo</a>
+58
View File
@@ -0,0 +1,58 @@
#############
## Builder ##
#############
FROM --platform=linux/amd64 rust:slim as builder
ARG TARGETARCH
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER="aarch64-linux-gnu-gcc"
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-lgcc"
ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_LINKER="arm-linux-gnueabihf-ld"
COPY ./containerised/platform.sh .
RUN chmod +x ./platform.sh && ./platform.sh
RUN apt-get update && apt-get install $(cat /.compiler) -y
WORKDIR /usr/src
# Create blank project
RUN cargo new oxker
# We want dependencies cached, so copy those first
COPY Cargo.toml Cargo.lock /usr/src/oxker/
# Set the working directory
WORKDIR /usr/src/oxker
# Install target platform (Cross-Compilation)
RUN rustup target add $(cat /.platform)
# This is a dummy build to get the dependencies cached
RUN cargo build --target $(cat /.platform) --release
# Now copy in the rest of the sources
COPY src /usr/src/oxker/src/
## Touch main.rs to prevent cached release build
RUN touch /usr/src/oxker/src/main.rs
# This is the actual application build
RUN cargo build --release --target $(cat /.platform)
RUN cp /usr/src/oxker/target/$(cat /.platform)/release/oxker /
#############
## Runtime ##
#############
FROM alpine:latest AS runtime
# Copy application binary from builder image
COPY --from=builder /oxker /usr/local/bin
COPY ./containerised/start_oxker.sh ./
# Run the application
ENTRYPOINT [ "./start_oxker.sh"]
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
docker login
docker buildx prune
docker buildx build --platform linux/arm/v6,linux/arm64,linux/amd64 -t mrjackwills/oxker --push -f containerised/Dockerfile .
# Github as well?
# docker buildx build --platform linux/arm/v6,linux/arm64,linux/amd64 -t ghcr.io/mrjackwills/oxker --push -f containerised/Dockerfile .
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
# Used in Docker build to set platform dependent variables
case $TARGETARCH in
"amd64")
echo "x86_64-unknown-linux-musl" > /.platform
echo "" > /.compiler
;;
"arm64")
echo "aarch64-unknown-linux-musl" > /.platform
echo "gcc-aarch64-linux-gnu" > /.compiler
;;
"arm")
echo "arm-unknown-linux-musleabihf" > /.platform
echo "gcc-arm-linux-gnueabihf" > /.compiler
;;
esac
+7
View File
@@ -0,0 +1,7 @@
#!/bin/sh
set -e
# No idea why this is solving my issue, or even where the issue is originally coming from
sleep .1
exec /usr/local/bin/oxker "$@"