From 1fd756ed2a660b972d73c4c380e6e85044d7abf9 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Sun, 17 Jul 2022 20:04:06 +0100 Subject: [PATCH 1/8] enable docker builds --- .dockerignore | 6 ++ .woodpecker/.release.yml | 160 +++++++++++++++------------------------ Dockerfile | 38 +++++----- 3 files changed, 84 insertions(+), 120 deletions(-) diff --git a/.dockerignore b/.dockerignore index 6b1879e62..2b5f1abff 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,6 +6,12 @@ COPYING *file elixir_buildpack.config test/ +instance/ +_build +deps +test +benchmarks +docs/site # Required to get version !.git diff --git a/.woodpecker/.release.yml b/.woodpecker/.release.yml index c411dd2e9..8cf289c23 100644 --- a/.woodpecker/.release.yml +++ b/.woodpecker/.release.yml @@ -1,127 +1,87 @@ -matrix: - docker_prefix: - - "" - - arm64v8/ - - arm32v7/ - tag: - - amd64 - - arm64 - - arm - - include: - - tag: amd64 - docker_prefix: "" - -pipeline: - glibc: - when: - event: - - push - - tag - branch: - - develop - - stable - - refs/tags/v* - - refs/tags/stable-* - secrets: +variables: + &scw-secrets - SCW_ACCESS_KEY - SCW_SECRET_KEY - SCW_DEFAULT_ORGANIZATION_ID - image: ${docker_prefix}elixir:1.13 + &setup-scw-s3 + - wget https://github.com/scaleway/scaleway-cli/releases/download/v2.5.1/scaleway-cli_2.5.1_linux_amd64 + - mv scaleway-cli_2.5.1_linux_amd64 scaleway-cli + - chmod +x scaleway-cli + - ./scaleway-cli object config install type=rclone + &setup-hex + - mix local.hex --force + - mix local.rebar --force + &build-on + event: + - push + - tag + branch: + - develop + - stable + - refs/tags/v* + - refs/tags/stable-* + &tag-build + - export BUILD_TAG=$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"} + - export PLEROMA_BUILD_BRANCH=$BUILD_TAG + &clean + - rm -rf release || true + - rm -rf _build || true + - rm -rf /root/.mix + - rm scaleway-cli || true + - mix deps.clean --all + + +pipeline: + glibc: + image: hexpm/elixir:1.13.4-erlang-24.3.4.2-ubuntu-focal-20211006 + when: + <<: *build-on + secrets: + <<: *scw-secrets environment: MIX_ENV: prod commands: - apt-get update && apt-get install -y cmake libmagic-dev rclone zip imagemagick libmagic-dev - - wget https://github.com/scaleway/scaleway-cli/releases/download/v2.5.1/scaleway-cli_2.5.1_linux_amd64 - - mv scaleway-cli_2.5.1_linux_amd64 scaleway-cli - - chmod +x scaleway-cli - - ./scaleway-cli object config install type=rclone + <<: *clean + + <<: *setup-scw-s3 + - echo "import Mix.Config" > config/prod.secret.exs - - mix local.hex --force - - mix local.rebar --force - - export BUILD_TAG=$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"} - - export PLEROMA_BUILD_BRANCH=$BUILD_TAG - - mix deps.clean --all + <<: *setup-hex + <<: *tag-build + - mix deps.get --only prod - - mkdir release - mix release --path release - zip akkoma-${tag}.zip -r release - rclone copyto akkoma-${tag}.zip scaleway:akkoma-updates/$BUILD_TAG/akkoma-${tag}.zip musl: + image: hexpm/elixir:1.13.4-erlang-24.3.4.2-alpine-3.16.0 when: - event: - - push - - tag - branch: - - develop - - stable - - refs/tags/v* - - refs/tags/stable-* + <<: *build-on secrets: - - SCW_ACCESS_KEY - - SCW_SECRET_KEY - - SCW_DEFAULT_ORGANIZATION_ID - image: ${docker_prefix}elixir:1.13-alpine + <<: *scw-secrets environment: MIX_ENV: prod commands: - apk add git gcc g++ musl-dev make cmake file-dev rclone wget zip imagemagick - - rm -rf release || true - - rm -rf _build || true - - rm -rf /root/.mix - - rm scaleway-cli || true - - wget https://github.com/scaleway/scaleway-cli/releases/download/v2.5.1/scaleway-cli_2.5.1_linux_amd64 - - mv scaleway-cli_2.5.1_linux_amd64 scaleway-cli - - chmod +x scaleway-cli - - ./scaleway-cli object config install type=rclone + <<: *clean + <<: *setup-scw-s3 + <<: *setup-hex + <<: *tag-build - - mix local.hex --force - - mix local.rebar --force - - export BUILD_TAG=$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"} - - export PLEROMA_BUILD_BRANCH=$BUILD_TAG - - mix deps.clean --all - mix deps.get --only prod - mix release --path release - zip akkoma-${tag}.zip -r release - rclone copyto akkoma-${tag}.zip scaleway:akkoma-updates/$BUILD_TAG/akkoma-${tag}-musl.zip - musl1.1: + docker: + image: woodpeckerci/plugin-docker-buildx when: - event: - - push - - tag - branch: - - develop - - stable - - refs/tags/v* - - refs/tags/stable-* - secrets: - - SCW_ACCESS_KEY - - SCW_SECRET_KEY - - SCW_DEFAULT_ORGANIZATION_ID - image: voidlinux/voidlinux-musl - environment: - MIX_ENV: prod - commands: - - xbps-install -Suy || xbps-install -uy xbps - - xbps-install -Suy - - xbps-install -y git gcc musl-devel make cmake file-devel rclone wget zip libmagic elixir - - rm -rf release || true - - rm -rf _build || true - - rm -rf /root/.mix - - rm scaleway-cli || true - - wget https://github.com/scaleway/scaleway-cli/releases/download/v2.5.1/scaleway-cli_2.5.1_linux_amd64 - - mv scaleway-cli_2.5.1_linux_amd64 scaleway-cli - - chmod +x scaleway-cli - - ./scaleway-cli object config install type=rclone - - - mix local.hex --force - - mix local.rebar --force - - export BUILD_TAG=$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"} - - export PLEROMA_BUILD_BRANCH=$BUILD_TAG - - mix deps.clean --all - - mix deps.get --only prod - - mix release --path release - - zip akkoma-${tag}.zip -r release - - rclone copyto akkoma-${tag}.zip scaleway:akkoma-updates/$BUILD_TAG/akkoma-${tag}-musl11.zip + <<: *build-on + secrets: [docker_username, docker_password] + settings: + repo: akkoma/akkoma + dockerfile: Dockerfile + platforms: linux/arm/v7,linux/arm64/v8,linux/amd64 + tag: [latest, alpine] diff --git a/Dockerfile b/Dockerfile index c51ebbab0..e6210affb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,52 +1,50 @@ -FROM elixir:1.9-alpine as build +FROM hexpm/elixir:1.13.4-erlang-24.3.4.2-alpine-3.16.0 as build COPY . . ENV MIX_ENV=prod RUN apk add git gcc g++ musl-dev make cmake file-dev &&\ - echo "import Mix.Config" > config/prod.secret.exs &&\ + echo "import Config" > config/prod.secret.exs &&\ mix local.hex --force &&\ mix local.rebar --force &&\ mix deps.get --only prod &&\ mkdir release &&\ mix release --path release -FROM alpine:3.14 +FROM alpine:3.16 ARG BUILD_DATE ARG VCS_REF -LABEL maintainer="ops@pleroma.social" \ - org.opencontainers.image.title="pleroma" \ - org.opencontainers.image.description="Pleroma for Docker" \ - org.opencontainers.image.authors="ops@pleroma.social" \ - org.opencontainers.image.vendor="pleroma.social" \ - org.opencontainers.image.documentation="https://git.pleroma.social/pleroma/pleroma" \ +LABEL org.opencontainers.image.title="akkoma" \ + org.opencontainers.image.description="Akkoma for Docker" \ + org.opencontainers.image.vendor="akkoma.dev" \ + org.opencontainers.image.documentation="https://docs.akkoma.dev/stable/" \ org.opencontainers.image.licenses="AGPL-3.0" \ - org.opencontainers.image.url="https://pleroma.social" \ + org.opencontainers.image.url="https://akkoma.dev" \ org.opencontainers.image.revision=$VCS_REF \ org.opencontainers.image.created=$BUILD_DATE -ARG HOME=/opt/pleroma -ARG DATA=/var/lib/pleroma +ARG HOME=/opt/akkoma +ARG DATA=/var/lib/akkoma RUN apk update &&\ apk add exiftool ffmpeg imagemagick libmagic ncurses postgresql-client &&\ - adduser --system --shell /bin/false --home ${HOME} pleroma &&\ + adduser --system --shell /bin/false --home ${HOME} akkoma &&\ mkdir -p ${DATA}/uploads &&\ mkdir -p ${DATA}/static &&\ - chown -R pleroma ${DATA} &&\ - mkdir -p /etc/pleroma &&\ - chown -R pleroma /etc/pleroma + chown -R akkoma ${DATA} &&\ + mkdir -p /etc/akkoma &&\ + chown -R akkoma /etc/akkoma -USER pleroma +USER akkoma -COPY --from=build --chown=pleroma:0 /release ${HOME} +COPY --from=build --chown=akkoma:0 /release ${HOME} -COPY ./config/docker.exs /etc/pleroma/config.exs +COPY ./config/docker.exs /etc/akkoma/config.exs COPY ./docker-entrypoint.sh ${HOME} EXPOSE 4000 -ENTRYPOINT ["/opt/pleroma/docker-entrypoint.sh"] +ENTRYPOINT ["/opt/akkoma/docker-entrypoint.sh"] -- 2.34.1 From 78ec1d5b3afce33e491a30076d5df5482711e764 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Sun, 17 Jul 2022 20:09:17 +0100 Subject: [PATCH 2/8] fix anchor usage --- .woodpecker/.release.yml | 75 +++++++++++++++------------------------- 1 file changed, 28 insertions(+), 47 deletions(-) diff --git a/.woodpecker/.release.yml b/.woodpecker/.release.yml index 8cf289c23..c9c63c78b 100644 --- a/.woodpecker/.release.yml +++ b/.woodpecker/.release.yml @@ -3,53 +3,38 @@ variables: - SCW_ACCESS_KEY - SCW_SECRET_KEY - SCW_DEFAULT_ORGANIZATION_ID - &setup-scw-s3 - - wget https://github.com/scaleway/scaleway-cli/releases/download/v2.5.1/scaleway-cli_2.5.1_linux_amd64 - - mv scaleway-cli_2.5.1_linux_amd64 scaleway-cli - - chmod +x scaleway-cli - - ./scaleway-cli object config install type=rclone - &setup-hex - - mix local.hex --force - - mix local.rebar --force + &setup-scw-s3 "wget https://github.com/scaleway/scaleway-cli/releases/download/v2.5.1/scaleway-cli_2.5.1_linux_amd64 && mv scaleway-cli_2.5.1_linux_amd64 scaleway-cli && chmod +x scaleway-cli && ./scaleway-cli object config install type=rclone" + + &setup-hex "mix local.hex --force && mix local.rebar --force" &build-on - event: - - push - - tag - branch: - - develop - - stable - - refs/tags/v* - - refs/tags/stable-* - &tag-build - - export BUILD_TAG=$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"} - - export PLEROMA_BUILD_BRANCH=$BUILD_TAG - &clean - - rm -rf release || true - - rm -rf _build || true - - rm -rf /root/.mix - - rm scaleway-cli || true - - mix deps.clean --all + when: + event: + - push + - tag + branch: + - develop + - stable + - refs/tags/v* + - refs/tags/stable-* + &tag-build 'export BUILD_TAG=$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"} && export PLEROMA_BUILD_BRANCH=$BUILD_TAG' + + &clean "(rm -rf release || true) && (rm -rf _build || true) && (rm -rf /root/.mix) && (rm scaleway-cli || true) && (mix deps.clean --all)" pipeline: glibc: image: hexpm/elixir:1.13.4-erlang-24.3.4.2-ubuntu-focal-20211006 - when: - <<: *build-on - secrets: - <<: *scw-secrets + <<: *build-on + secrets: *scw-secrets environment: MIX_ENV: prod commands: - apt-get update && apt-get install -y cmake libmagic-dev rclone zip imagemagick libmagic-dev - <<: *clean - - <<: *setup-scw-s3 - + - *clean + - *setup-scw-s3 - echo "import Mix.Config" > config/prod.secret.exs - <<: *setup-hex - <<: *tag-build - + - *setup-hex + - *tag-build - mix deps.get --only prod - mix release --path release - zip akkoma-${tag}.zip -r release @@ -57,19 +42,16 @@ pipeline: musl: image: hexpm/elixir:1.13.4-erlang-24.3.4.2-alpine-3.16.0 - when: - <<: *build-on - secrets: - <<: *scw-secrets + <<: *build-on + secrets: *scw-secrets environment: MIX_ENV: prod commands: - apk add git gcc g++ musl-dev make cmake file-dev rclone wget zip imagemagick - <<: *clean - <<: *setup-scw-s3 - <<: *setup-hex - <<: *tag-build - + - *clean + - *setup-scw-s3 + - *setup-hex + - *tag-build - mix deps.get --only prod - mix release --path release - zip akkoma-${tag}.zip -r release @@ -77,8 +59,7 @@ pipeline: docker: image: woodpeckerci/plugin-docker-buildx - when: - <<: *build-on + <<: *build-on secrets: [docker_username, docker_password] settings: repo: akkoma/akkoma -- 2.34.1 From 1d5c6aeaf2684d6d90f2817e7b61a73e194404cc Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Sun, 17 Jul 2022 20:11:27 +0100 Subject: [PATCH 3/8] fix anchor syntax --- .woodpecker/.release.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.woodpecker/.release.yml b/.woodpecker/.release.yml index c9c63c78b..9f5565891 100644 --- a/.woodpecker/.release.yml +++ b/.woodpecker/.release.yml @@ -1,12 +1,12 @@ variables: - &scw-secrets + - &scw-secrets - SCW_ACCESS_KEY - SCW_SECRET_KEY - SCW_DEFAULT_ORGANIZATION_ID - &setup-scw-s3 "wget https://github.com/scaleway/scaleway-cli/releases/download/v2.5.1/scaleway-cli_2.5.1_linux_amd64 && mv scaleway-cli_2.5.1_linux_amd64 scaleway-cli && chmod +x scaleway-cli && ./scaleway-cli object config install type=rclone" + - &setup-scw-s3 "wget https://github.com/scaleway/scaleway-cli/releases/download/v2.5.1/scaleway-cli_2.5.1_linux_amd64 && mv scaleway-cli_2.5.1_linux_amd64 scaleway-cli && chmod +x scaleway-cli && ./scaleway-cli object config install type=rclone" - &setup-hex "mix local.hex --force && mix local.rebar --force" - &build-on + - &setup-hex "mix local.hex --force && mix local.rebar --force" + - &build-on when: event: - push @@ -16,9 +16,9 @@ variables: - stable - refs/tags/v* - refs/tags/stable-* - &tag-build 'export BUILD_TAG=$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"} && export PLEROMA_BUILD_BRANCH=$BUILD_TAG' + - &tag-build 'export BUILD_TAG=$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"} && export PLEROMA_BUILD_BRANCH=$BUILD_TAG' - &clean "(rm -rf release || true) && (rm -rf _build || true) && (rm -rf /root/.mix) && (rm scaleway-cli || true) && (mix deps.clean --all)" + - &clean "(rm -rf release || true) && (rm -rf _build || true) && (rm -rf /root/.mix) && (rm scaleway-cli || true) && (mix deps.clean --all)" pipeline: -- 2.34.1 From 8cb3a5216b4ecc49529cdcccb24570928e91c817 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Sun, 17 Jul 2022 20:12:08 +0100 Subject: [PATCH 4/8] release on docker-build --- .woodpecker/.release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker/.release.yml b/.woodpecker/.release.yml index 9f5565891..0d18cd06a 100644 --- a/.woodpecker/.release.yml +++ b/.woodpecker/.release.yml @@ -16,6 +16,7 @@ variables: - stable - refs/tags/v* - refs/tags/stable-* + - docker-build - &tag-build 'export BUILD_TAG=$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"} && export PLEROMA_BUILD_BRANCH=$BUILD_TAG' - &clean "(rm -rf release || true) && (rm -rf _build || true) && (rm -rf /root/.mix) && (rm scaleway-cli || true) && (mix deps.clean --all)" -- 2.34.1 From e414f96728190352a7fc3b1d7427ff2d5031521f Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Sun, 17 Jul 2022 20:15:25 +0100 Subject: [PATCH 5/8] allow failure of deps clean --- .woodpecker/.release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/.release.yml b/.woodpecker/.release.yml index 0d18cd06a..51c6ad226 100644 --- a/.woodpecker/.release.yml +++ b/.woodpecker/.release.yml @@ -19,7 +19,7 @@ variables: - docker-build - &tag-build 'export BUILD_TAG=$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"} && export PLEROMA_BUILD_BRANCH=$BUILD_TAG' - - &clean "(rm -rf release || true) && (rm -rf _build || true) && (rm -rf /root/.mix) && (rm scaleway-cli || true) && (mix deps.clean --all)" + - &clean "(rm -rf release || true) && (rm -rf _build || true) && (rm -rf /root/.mix) && (rm scaleway-cli || true) && (mix deps.clean --all || true)" pipeline: -- 2.34.1 From f3b532c49fd9b62024a09cb556477821fcfc98ec Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Sun, 17 Jul 2022 20:20:39 +0100 Subject: [PATCH 6/8] include git --- .woodpecker/.release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/.release.yml b/.woodpecker/.release.yml index 51c6ad226..244532831 100644 --- a/.woodpecker/.release.yml +++ b/.woodpecker/.release.yml @@ -30,7 +30,7 @@ pipeline: environment: MIX_ENV: prod commands: - - apt-get update && apt-get install -y cmake libmagic-dev rclone zip imagemagick libmagic-dev + - apt-get update && apt-get install -y cmake libmagic-dev rclone zip imagemagick libmagic-dev git - *clean - *setup-scw-s3 - echo "import Mix.Config" > config/prod.secret.exs -- 2.34.1 From 1e869a2c95bdeeda152a50b8d4699cc904c6facc Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Mon, 18 Jul 2022 01:19:02 +0100 Subject: [PATCH 7/8] use elixir image --- .woodpecker/.release.yml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/.woodpecker/.release.yml b/.woodpecker/.release.yml index 244532831..edcb10743 100644 --- a/.woodpecker/.release.yml +++ b/.woodpecker/.release.yml @@ -24,7 +24,7 @@ variables: pipeline: glibc: - image: hexpm/elixir:1.13.4-erlang-24.3.4.2-ubuntu-focal-20211006 + image: elixir:1.13 <<: *build-on secrets: *scw-secrets environment: @@ -42,7 +42,7 @@ pipeline: - rclone copyto akkoma-${tag}.zip scaleway:akkoma-updates/$BUILD_TAG/akkoma-${tag}.zip musl: - image: hexpm/elixir:1.13.4-erlang-24.3.4.2-alpine-3.16.0 + image: elixir:1.13-alpine <<: *build-on secrets: *scw-secrets environment: @@ -57,13 +57,3 @@ pipeline: - mix release --path release - zip akkoma-${tag}.zip -r release - rclone copyto akkoma-${tag}.zip scaleway:akkoma-updates/$BUILD_TAG/akkoma-${tag}-musl.zip - - docker: - image: woodpeckerci/plugin-docker-buildx - <<: *build-on - secrets: [docker_username, docker_password] - settings: - repo: akkoma/akkoma - dockerfile: Dockerfile - platforms: linux/arm/v7,linux/arm64/v8,linux/amd64 - tag: [latest, alpine] -- 2.34.1 From feec0c926b01ec823220e8195e263704ee11b497 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Mon, 18 Jul 2022 01:22:53 +0100 Subject: [PATCH 8/8] don't build on test branch --- .woodpecker/.release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.woodpecker/.release.yml b/.woodpecker/.release.yml index edcb10743..e672c1251 100644 --- a/.woodpecker/.release.yml +++ b/.woodpecker/.release.yml @@ -16,7 +16,6 @@ variables: - stable - refs/tags/v* - refs/tags/stable-* - - docker-build - &tag-build 'export BUILD_TAG=$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"} && export PLEROMA_BUILD_BRANCH=$BUILD_TAG' - &clean "(rm -rf release || true) && (rm -rf _build || true) && (rm -rf /root/.mix) && (rm scaleway-cli || true) && (mix deps.clean --all || true)" -- 2.34.1