feat: switch to scratch docker container

This commit is contained in:
Jack Wills
2023-02-03 21:40:14 +00:00
parent a76bfbcbd9
commit 17b71b6b41
5 changed files with 56 additions and 27 deletions
+4 -2
View File
@@ -51,10 +51,12 @@ RUN cp /usr/src/oxker/target/$(cat /.platform)/release/oxker /
FROM alpine:latest AS runtime
# Set an ENV that we're running in a container, so that the application can sleep for 250ms at start
ENV OXKER_RUNTIME=container
# Copy application binary from builder image
COPY --from=builder /oxker /usr/local/bin
COPY ./containerised/start_oxker.sh ./
# Run the application
# this is used in the application itself, to stop itself show when running from a docker container, so DO NOT EDIT
ENTRYPOINT [ "./start_oxker.sh"]
ENTRYPOINT [ "./app/oxker"]
+11 -4
View File
@@ -1,16 +1,23 @@
#############
## Runtime ##
#############
FROM scratch
FROM alpine:latest AS runtime
# Set env that we're running in a container, so that the application can sleep for 250ms at start
ENV OXKER_RUNTIME=container
# Copy application binary from builder image
COPY ./target/x86_64-unknown-linux-musl/release/oxker /usr/local/bin
COPY ./containerised/start_oxker.sh ./
COPY ./target/x86_64-unknown-linux-musl/release/oxker /app/
# Run the application
# this is used in the application itself, to stop itself show when running from a docker container, so DO NOT EDIT
ENTRYPOINT [ "./start_oxker.sh"]
ENTRYPOINT [ "./app/oxker"]
# Dev build for testing
# docker build -t oxker_dev -f Dockerfile . && docker run --rm -it --volume /var/run/docker.sock:/var/run/docker.sock:ro oxker_dev
# Dev build one liner, x86 host
# docker image prune -a; cargo build --release --target x86_64-unknown-linux-musl && docker build -t oxker_dev -f containerised/Dockerfile_dev . && docker run --rm -it --volume /var/run/docker.sock:/var/run/docker.sock:ro oxker_dev
## One liner to build musl program, build docker image, then execute the image
# cargo build --release --target x86_64-unknown-linux-musl && docker build -t oxker_dev -f containerised/Dockerfile . && docker run --rm -it --volume /var/run/docker.sock:/var/run/docker.sock:ro oxker_dev
-8
View File
@@ -1,8 +0,0 @@
#!/bin/sh
set -e
# Without this sleep, the docker image will instantly close
# No idea why this is solving my issue, or even where the issue is originally coming from
sleep .1
exec /usr/local/bin/oxker "$@"