🐳 build: set up app package for ptth_relay Docker images

main
_ 2021-02-20 17:49:02 +00:00
parent 498d69eeb9
commit 10465dfb46
6 changed files with 41 additions and 9 deletions

View File

@ -1,3 +1,5 @@
/config /config
/ptth_build_*
/ptth_server_build_*
/ptth_latest.tar.gz /ptth_latest.tar.gz
/target /target

3
.gitignore vendored
View File

@ -1,5 +1,6 @@
/config
/*.tar.gz /*.tar.gz
/app_packages
/config
/ptth_server.toml /ptth_server.toml
/ptth_relay.toml /ptth_relay.toml
/ptth_build_L6KLMVS6/ /ptth_build_L6KLMVS6/

View File

@ -4,8 +4,6 @@
# rust:1.48-slim-buster # rust:1.48-slim-buster
FROM rust@sha256:cb6b98346ef41a2062d4d8f099127d880f2ef7c1515d00215fc9ea713b99167b as build FROM rust@sha256:cb6b98346ef41a2062d4d8f099127d880f2ef7c1515d00215fc9ea713b99167b as build
#RUN apk add libseccomp-dev
WORKDIR / WORKDIR /
ENV USER root ENV USER root
@ -62,21 +60,21 @@ cargo build --release -p ptth_relay && \
cargo test --release -p ptth_relay cargo test --release -p ptth_relay
# debian:buster-slim # debian:buster-slim
FROM debian@sha256:240f770008bdc538fecc8d3fa7a32a533eac55c14cbc56a9a8a6f7d741b47e33 FROM debian@sha256:13f0764262a064b2dd9f8a828bbaab29bdb1a1a0ac6adc8610a0a5f37e514955
RUN apt-get update \ RUN apt-get update \
&& apt-get upgrade -y \ && apt-get upgrade -y \
&& apt-get install -y libssl1.1 ca-certificates tini && apt-get install -y libssl1.1 ca-certificates tini
RUN addgroup --gid 10001 nonroot && adduser --system --uid 10000 --gid 10001 nonroot RUN addgroup --gid 10001 ptth_user && adduser --system --uid 10000 --gid 10001 ptth_user
USER nonroot USER ptth_user
WORKDIR /home/nonroot WORKDIR /home/ptth_user
COPY --from=build /ptth/target/release/ptth_relay ./ COPY --from=build /ptth/target/release/ptth_relay ./
COPY --from=build /ptth/handlebars ./handlebars COPY --from=build /ptth/handlebars/relay ./handlebars/relay
ARG git_version ARG git_version
RUN echo -n "$git_version" > ./git_version.txt RUN echo -n "$git_version" > ./git_version.txt
ENTRYPOINT ["/usr/bin/tini", "--", "./ptth_relay"] CMD ["/usr/bin/tini", "--", "./ptth_relay"]

15
app_package_Dockerfile Normal file
View File

@ -0,0 +1,15 @@
# debian:buster-slim
FROM debian@sha256:13f0764262a064b2dd9f8a828bbaab29bdb1a1a0ac6adc8610a0a5f37e514955
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y libssl1.1 ca-certificates tini
RUN addgroup --gid 10001 ptth_user && adduser --system --uid 10000 --gid 10001 ptth_user
USER ptth_user
WORKDIR /home/ptth_user
COPY ./run_app_package.bash ./
ENTRYPOINT ["/usr/bin/tini", "--", "bash", "./run_app_package.bash"]

9
build_app_package.bash Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
GIT_COMMITISH=$(git rev-parse main)
mkdir -p app_packages
git archive --format=tar "$GIT_COMMITISH" | sudo docker build -t ptth:latest --build-arg "git_version=$GIT_COMMITISH" -
sudo docker run --rm ptth:latest tar -c ptth_relay handlebars | gzip > app_packages/garbage.tar.gz

7
run_app_package.bash Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
tar -xf "$1"
exec ./ptth_relay