From 9a6a85745580451453607ae6895f1b20466a18ee Mon Sep 17 00:00:00 2001 From: liushuyu Date: Wed, 23 Aug 2023 11:53:32 -0600 Subject: [PATCH] docker: use Ubuntu chisel image --- Dockerfile | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2a4d50f..a7035ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,38 @@ # syntax=docker/dockerfile:1.3 -FROM debian:bookworm AS build +ARG UBUNTU_RELEASE=23.04 +ARG USER=ubuntu UID=101 GROUP=ubuntu GID=101 + +### BOILERPLATE BEGIN ### + +FROM golang:1.20 AS chisel +ARG UBUNTU_RELEASE +RUN git clone -b ubuntu-${UBUNTU_RELEASE} https://github.com/canonical/chisel-releases /opt/chisel-releases \ + && git clone --depth 1 -b main https://github.com/canonical/chisel /opt/chisel +WORKDIR /opt/chisel +RUN go generate internal/deb/version.go \ + && go build ./cmd/chisel + +FROM ubuntu:$UBUNTU_RELEASE AS builder +SHELL ["/bin/bash", "-oeux", "pipefail", "-c"] +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* +COPY --from=chisel /opt/chisel/chisel /usr/bin/ + +FROM builder AS rootfs-prep +ARG USER UID GROUP GID +RUN mkdir -p /rootfs/etc \ + && echo "$GROUP:x:$GID:" >/rootfs/etc/group \ + && echo "$USER:x:$UID:$GID::/nohome:/noshell" >/rootfs/etc/passwd + +FROM scratch AS image-prep +ARG UID GID +USER $UID:$GID + +### BOILERPLATE END ### + +FROM ubuntu:$UBUNTU_RELEASE AS build ENV DEBIAN_FRONTEND=noninteractive ARG USE_CCACHE RUN apt-get update && apt-get -y full-upgrade && \ @@ -11,10 +44,22 @@ RUN --mount=type=cache,id=ccache,target=/root/.ccache \ /root/build-files/.ci/fetch.sh /root/citra-canary && \ cd /root/citra-canary && /root/build-files/.ci/build.sh -FROM gcr.io/distroless/cc-debian11 AS final +FROM rootfs-prep AS sliced-deps +COPY --from=chisel /opt/chisel-releases /opt/chisel-releases +RUN chisel cut --release /opt/chisel-releases --root /rootfs \ + base-files_base \ + base-files_release-info \ + ca-certificates_data \ + libgcc-s1_libs \ + libc6_libs \ + libssl3_libs \ + libstdc++6_libs \ + openssl_config + +FROM image-prep AS final +COPY --from=sliced-deps /rootfs / LABEL maintainer="citraemu" # Create app directory WORKDIR /usr/src/app COPY --from=build /root/citra-canary/build/bin/Release/citra-room /usr/src/app - ENTRYPOINT [ "/usr/src/app/citra-room" ]