feat: first working alpine docker container of self
This commit is contained in:
+36
-92
@@ -1,103 +1,47 @@
|
|||||||
# FROM debian:bullseye-slim
|
#############
|
||||||
# FROM
|
## Builder ##
|
||||||
FROM alpine:latest
|
#############
|
||||||
# FROM scratch
|
|
||||||
|
|
||||||
# DOCKER_GUID=1000 \
|
FROM rust:1.63.0-slim as builder
|
||||||
# DOCKER_UID=1000 \
|
|
||||||
# DOCKER_TIME_CONT=America \
|
|
||||||
# DOCKER_TIME_CITY=New_York \
|
|
||||||
# ARG DOCKER_APP_USER=oxker \
|
|
||||||
# DOCKER_APP_GROUP=docker
|
|
||||||
|
|
||||||
# ENV TZ=${DOCKER_TIME_CONT}/${DOCKER_TIME_CITY}
|
WORKDIR /usr/src
|
||||||
|
|
||||||
# RUN apt-get update \
|
# Create blank project
|
||||||
# && apt-get install -y ca-certificates wget \
|
RUN USER=root cargo new oxker
|
||||||
# && update-ca-certificates \
|
|
||||||
# RUN groupadd ${DOCKER_APP_GROUP}
|
|
||||||
# RUN useradd --no-create-home --no-log-init ${DOCKER_APP_USER}
|
|
||||||
# && mkdir /healthcheck /logs \
|
|
||||||
# && chown ${DOCKER_APP_USER}:${DOCKER_APP_GROUP} /logs
|
|
||||||
|
|
||||||
WORKDIR /app
|
# We want dependencies cached, so copy those first.
|
||||||
|
COPY Cargo.toml Cargo.lock /usr/src/oxker/
|
||||||
|
|
||||||
# COPY --chown=${DOCKER_APP_USER}:${DOCKER_APP_GROUP} docker/healthcheck/health_api.sh /healthcheck
|
# Set the working directory
|
||||||
|
WORKDIR /usr/src/oxker
|
||||||
|
|
||||||
# Copy from local release destination
|
## Install target platform (Cross-Compilation) --> Needed for Alpine
|
||||||
# COPY --chown=${DOCKER_APP_USER} target/release/oxker /app/
|
RUN rustup target add x86_64-unknown-linux-musl
|
||||||
# COPY target/release/oxker .
|
|
||||||
# RUN mkdir app
|
|
||||||
COPY /target/x86_64-unknown-linux-musl/release/oxker ./
|
|
||||||
COPY ./start_oxker.sh ./
|
|
||||||
RUN chmod +x /app/start_oxker.sh
|
|
||||||
|
|
||||||
# Use an unprivileged user
|
# This is a dummy build to get the dependencies cached.
|
||||||
# USER ${DOCKER_APP_USER}
|
RUN cargo build --target x86_64-unknown-linux-musl --release
|
||||||
ENV RUST_BACKTRACE=full
|
|
||||||
# ENTRYPOINT ["./oxker" ]
|
|
||||||
# CMD [ "./oxker"]
|
|
||||||
ENTRYPOINT ["/app/start_oxker.sh"]
|
|
||||||
|
|
||||||
# docker run --rm -ti \
|
# Now copy in the rest of the sources
|
||||||
# --name=ctop \
|
COPY src /usr/src/oxker/src/
|
||||||
# --volume /var/run/docker.sock:/var/run/docker.sock:ro \
|
|
||||||
# # quay.io/vektorlab/ctop:latest
|
|
||||||
|
|
||||||
|
## 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 --target x86_64-unknown-linux-musl --release
|
||||||
|
|
||||||
|
#############
|
||||||
|
## Runtime ##
|
||||||
|
#############
|
||||||
|
|
||||||
|
FROM alpine:latest AS runtime
|
||||||
|
|
||||||
|
# Copy application binary from builder image
|
||||||
|
COPY --from=builder /usr/src/oxker/target/x86_64-unknown-linux-musl/release/oxker /usr/local/bin
|
||||||
|
COPY start_oxker.sh ./
|
||||||
|
RUN chmod +x /start_oxker.sh
|
||||||
|
|
||||||
|
# Run the application
|
||||||
|
ENTRYPOINT [ "./start_oxker.sh"]
|
||||||
|
|
||||||
# docker run --rm -it --volume /var/run/docker.sock:/var/run/docker.sock:ro oxker
|
# docker run --rm -it --volume /var/run/docker.sock:/var/run/docker.sock:ro oxker
|
||||||
|
|
||||||
# docker run --rm -it --volume /var/run/docker.sock:/var/run/docker.sock:ro ghcr.io/mrjackwills/oxker:latest
|
|
||||||
# could get arch, and then download appropoatley from github?
|
|
||||||
|
|
||||||
# FROM rust:latest as cargo-build
|
|
||||||
|
|
||||||
# WORKDIR /build
|
|
||||||
# ENV RUSTFLAGS="-C target-feature=+crt-static"
|
|
||||||
|
|
||||||
# COPY Cargo* ./build
|
|
||||||
# COPY src/ ./build
|
|
||||||
|
|
||||||
# RUN cargo build --release --target x86_64-unknown-linux-gnu
|
|
||||||
|
|
||||||
# #####################################
|
|
||||||
|
|
||||||
|
|
||||||
# #####################################
|
|
||||||
|
|
||||||
# FROM scratch
|
|
||||||
|
|
||||||
# COPY --from=cargo-build /build/target/x86_64-unknown-linux-gnu/release/oxker /oxker
|
|
||||||
|
|
||||||
# ENTRYPOINT [ "/oxker" ]
|
|
||||||
|
|
||||||
# FROM rust:latest AS build
|
|
||||||
# WORKDIR /oxker_build
|
|
||||||
|
|
||||||
# # Download the target for static linking.
|
|
||||||
# RUN rustup target add x86_64-unknown-linux-musl
|
|
||||||
|
|
||||||
# # Create a dummy project and build the app's dependencies.
|
|
||||||
# # If the Cargo.toml or Cargo.lock files have not changed,
|
|
||||||
# # we can use the docker build cache and skip these (typically slow) steps.
|
|
||||||
# RUN USER=root cargo new oxker --bin
|
|
||||||
# WORKDIR /oxker_build
|
|
||||||
# COPY Cargo.toml Cargo.lock ./
|
|
||||||
# # CMD ["sleep", "6000"]
|
|
||||||
|
|
||||||
# # RUN cargo build --release
|
|
||||||
|
|
||||||
# # Copy the source and build the application.
|
|
||||||
# COPY src ./src/
|
|
||||||
# RUN cargo install --target x86_64-unknown-linux-musl --path .
|
|
||||||
|
|
||||||
# # Copy the statically-linked binary into a scratch container.
|
|
||||||
# FROM scratch
|
|
||||||
# COPY --from=build /oxker_build/bin/oxker .
|
|
||||||
# # USER 1000
|
|
||||||
# CMD ["./oxker"]
|
|
||||||
|
|
||||||
# cross build --target x86_64-unknown-linux-musl --release
|
|
||||||
|
|
||||||
# rustup target add x86_64-unknown-linux-musl
|
|
||||||
# cargo build --release --target=x86_64-unknown-linux-musl
|
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# No idea why this is sloving my issue, or even where the issue is originally coming from
|
# No idea why this is solving my issue, or even where the issue is originally coming from
|
||||||
sleep 1
|
sleep .1
|
||||||
|
|
||||||
exec ./oxker "$@"
|
exec /usr/local/bin/oxker "$@"
|
||||||
Reference in New Issue
Block a user