From 74e2f335beabbae907dad01baadb74cd1f7776f5 Mon Sep 17 00:00:00 2001 From: Kegan Myers Date: Sun, 23 Jul 2023 13:20:16 -0500 Subject: [PATCH] move git clone into container --- Dockerfile | 19 ++++++++++++++----- build.sh | 10 +++++++--- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 00e1760..a712977 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,13 +3,22 @@ FROM registry.nrd.li/nrdli/akkoma-base:${AKKOMA_COMMIT} ENV PROD_SECRET_FILE=/config/prod.secret.exs -ADD akkoma /opt/akkoma -ADD prod.exs /opt/akkoma/config/prod.exs - USER root -RUN mkdir /config && touch /config/prod.secret.exs && chown -R 1000:1000 /opt && chown -R 1000:1000 /config +RUN mkdir -p "$(dirname "${PROD_SECRET_FILE}")" && \ + touch "${PROD_SECRET_FILE}" && \ + chown -R 1000:1000 "$(dirname "${PROD_SECRET_FILE}")" USER akkoma -RUN mix deps.get && mix compile +WORKDIR /opt +RUN rm -rf akkoma && \ + git clone https://akkoma.dev/AkkomaGang/akkoma.git akkoma && \ + git fetch --all && \ + git checkout "${AKKOMA_COMMIT}" + +ADD --chown=akkoma:akkoma prod.exs /opt/akkoma/config/prod.exs +WORKDIR /opt/akkoma + +RUN mix deps.get +RUN mix compile RUN mix pleroma.frontend install pleroma-fe --ref stable RUN mix pleroma.frontend install admin-fe --ref stable diff --git a/build.sh b/build.sh index e79c246..310abb8 100755 --- a/build.sh +++ b/build.sh @@ -6,21 +6,25 @@ LOCAL_COMMIT=$(git rev-parse HEAD) AKKOMA_BASE_IMAGE="registry.nrd.li/nrdli/akkoma-base:${AKKOMA_COMMIT}" AKKOMA_FINAL_IMAGE="registry.nrd.li/nrdli/akkoma:${LOCAL_COMMIT}" -if [ ! -d akkoma ]; then - git clone https://akkoma.dev/AkkomaGang/akkoma.git akkoma +# clone akkoma source code +if [ -d akkoma ]; then + rm -rf akkoma fi +git clone https://akkoma.dev/AkkomaGang/akkoma.git akkoma pushd akkoma git fetch --all git checkout "${AKKOMA_COMMIT}" if [ "$(git rev-parse HEAD)" != "${AKKOMA_COMMIT}" ]; then exit 1 fi + +# build and store base image docker build \ -t "${AKKOMA_BASE_IMAGE}" \ . docker push "${AKKOMA_BASE_IMAGE}" -popd +# run install steps for akkoma docker build \ -t "${AKKOMA_FINAL_IMAGE}" \ --build-arg "AKKOMA_COMMIT=${AKKOMA_COMMIT}" \