Refactor CI build (#80)
authorfloatingghost <hannah@coffee-and-dreams.uk>
Mon, 18 Jul 2022 10:17:24 +0000 (10:17 +0000)
committerfloatingghost <hannah@coffee-and-dreams.uk>
Mon, 18 Jul 2022 10:17:24 +0000 (10:17 +0000)
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/80

.dockerignore
.woodpecker/.release.yml
Dockerfile

index 6b1879e62978d641b3b9512414ff19b35affd5f0..2b5f1abff4f1b32db53ace024b6efec15d3a02db 100644 (file)
@@ -6,6 +6,12 @@ COPYING
 *file
 elixir_buildpack.config
 test/
+instance/
+_build
+deps
+test
+benchmarks
+docs/site
 
 # Required to get version
 !.git
index c411dd2e998b711aa166102934299d642925e4c6..e672c1251e1b26c7886efe033d2dac58aab9b6b4 100644 (file)
-matrix:
-  docker_prefix:
-  - ""
-  - arm64v8/
-  - arm32v7/
-  tag:
-  - amd64
-  - arm64
-  - arm
-
-  include:
-  - tag: amd64
-    docker_prefix: ""
+variables:
+  - &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"
 
-pipeline:
-  glibc:
+  - &setup-hex "mix local.hex --force &&  mix local.rebar --force"
+  - &build-on
     when:
       event:
-        - push
-        - tag
+      - push
+      - tag
       branch:
-        - develop
-        - stable
-        - refs/tags/v*
-        - refs/tags/stable-*
-    secrets:
-    - SCW_ACCESS_KEY
-    - SCW_SECRET_KEY
-    - SCW_DEFAULT_ORGANIZATION_ID
-    image: ${docker_prefix}elixir:1.13
+      - 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 || true)"
+
+
+pipeline:
+  glibc:
+    image: elixir:1.13
+    <<: *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
+      - 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
-      - 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:
-    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: ${docker_prefix}elixir:1.13-alpine
+    image: elixir:1.13-alpine
+    <<: *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
-      - 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 
+      - *clean
+      - *setup-scw-s3
+      - *setup-hex
+      - *tag-build
       - 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:
-    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
index c51ebbab04755d161d1f1305b0ad8a4112f28a49..e6210affbf1600f6a2f00c1b0a408adfb308d3bf 100644 (file)
@@ -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"]