Browse Source

🐳 build: set up app package for ptth_relay Docker images

main
_ 2 years ago
parent
commit
10465dfb46
  1. 2
      .dockerignore
  2. 3
      .gitignore
  3. 14
      Dockerfile
  4. 15
      app_package_Dockerfile
  5. 9
      build_app_package.bash
  6. 7
      run_app_package.bash

2
.dockerignore

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

3
.gitignore

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

14
Dockerfile

@ -4,8 +4,6 @@
# rust:1.48-slim-buster
FROM rust@sha256:cb6b98346ef41a2062d4d8f099127d880f2ef7c1515d00215fc9ea713b99167b as build
#RUN apk add libseccomp-dev
WORKDIR /
ENV USER root
@ -62,21 +60,21 @@ cargo build --release -p ptth_relay && \
cargo test --release -p ptth_relay
# debian:buster-slim
FROM debian@sha256:240f770008bdc538fecc8d3fa7a32a533eac55c14cbc56a9a8a6f7d741b47e33
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 nonroot && adduser --system --uid 10000 --gid 10001 nonroot
RUN addgroup --gid 10001 ptth_user && adduser --system --uid 10000 --gid 10001 ptth_user
USER nonroot
WORKDIR /home/nonroot
USER ptth_user
WORKDIR /home/ptth_user
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
RUN echo -n "$git_version" > ./git_version.txt
ENTRYPOINT ["/usr/bin/tini", "--", "./ptth_relay"]
CMD ["/usr/bin/tini", "--", "./ptth_relay"]

15
app_package_Dockerfile

@ -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

@ -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

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