Refactor CI build #80

Merged
floatingghost merged 8 commits from refactor-ci into develop 2022-07-18 10:17:24 +00:00
3 changed files with 61 additions and 126 deletions

View file

@ -6,6 +6,12 @@ COPYING
*file *file
elixir_buildpack.config elixir_buildpack.config
test/ test/
instance/
_build
deps
test
benchmarks
docs/site
# Required to get version # Required to get version
!.git !.git

View file

@ -1,19 +1,12 @@
matrix: variables:
docker_prefix: - &scw-secrets
- "" - SCW_ACCESS_KEY
- arm64v8/ - SCW_SECRET_KEY
- arm32v7/ - SCW_DEFAULT_ORGANIZATION_ID
tag: - &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"
- amd64
- arm64
- arm
include: - &setup-hex "mix local.hex --force && mix local.rebar --force"
- tag: amd64 - &build-on
docker_prefix: ""
pipeline:
glibc:
when: when:
event: event:
- push - push
@ -23,105 +16,43 @@ pipeline:
- stable - stable
- refs/tags/v* - refs/tags/v*
- refs/tags/stable-* - refs/tags/stable-*
secrets: - &tag-build 'export BUILD_TAG=$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"} && export PLEROMA_BUILD_BRANCH=$BUILD_TAG'
- SCW_ACCESS_KEY
- SCW_SECRET_KEY - &clean "(rm -rf release || true) && (rm -rf _build || true) && (rm -rf /root/.mix) && (rm scaleway-cli || true) && (mix deps.clean --all || true)"
- SCW_DEFAULT_ORGANIZATION_ID
image: ${docker_prefix}elixir:1.13
pipeline:
glibc:
image: elixir:1.13
<<: *build-on
secrets: *scw-secrets
environment: environment:
MIX_ENV: prod MIX_ENV: prod
commands: 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
- wget https://github.com/scaleway/scaleway-cli/releases/download/v2.5.1/scaleway-cli_2.5.1_linux_amd64 - *clean
- mv scaleway-cli_2.5.1_linux_amd64 scaleway-cli - *setup-scw-s3
- chmod +x scaleway-cli
- ./scaleway-cli object config install type=rclone
- echo "import Mix.Config" > config/prod.secret.exs - echo "import Mix.Config" > config/prod.secret.exs
- mix local.hex --force - *setup-hex
- mix local.rebar --force - *tag-build
- 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 deps.get --only prod
- mkdir release
- mix release --path release - mix release --path release
- zip akkoma-${tag}.zip -r release - zip akkoma-${tag}.zip -r release
- rclone copyto akkoma-${tag}.zip scaleway:akkoma-updates/$BUILD_TAG/akkoma-${tag}.zip - rclone copyto akkoma-${tag}.zip scaleway:akkoma-updates/$BUILD_TAG/akkoma-${tag}.zip
musl: musl:
when: image: elixir:1.13-alpine
event: <<: *build-on
- push secrets: *scw-secrets
- 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
environment: environment:
MIX_ENV: prod MIX_ENV: prod
commands: commands:
- apk add git gcc g++ musl-dev make cmake file-dev rclone wget zip imagemagick - apk add git gcc g++ musl-dev make cmake file-dev rclone wget zip imagemagick
- rm -rf release || true - *clean
- rm -rf _build || true - *setup-scw-s3
- rm -rf /root/.mix - *setup-hex
- rm scaleway-cli || true - *tag-build
- 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 deps.get --only prod
- mix release --path release - mix release --path release
- zip akkoma-${tag}.zip -r release - zip akkoma-${tag}.zip -r release
- rclone copyto akkoma-${tag}.zip scaleway:akkoma-updates/$BUILD_TAG/akkoma-${tag}-musl.zip - 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

View 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 . . COPY . .
ENV MIX_ENV=prod ENV MIX_ENV=prod
RUN apk add git gcc g++ musl-dev make cmake file-dev &&\ 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.hex --force &&\
mix local.rebar --force &&\ mix local.rebar --force &&\
mix deps.get --only prod &&\ mix deps.get --only prod &&\
mkdir release &&\ mkdir release &&\
mix release --path release mix release --path release
FROM alpine:3.14 FROM alpine:3.16
ARG BUILD_DATE ARG BUILD_DATE
ARG VCS_REF ARG VCS_REF
LABEL maintainer="ops@pleroma.social" \ LABEL org.opencontainers.image.title="akkoma" \
org.opencontainers.image.title="pleroma" \ org.opencontainers.image.description="Akkoma for Docker" \
org.opencontainers.image.description="Pleroma for Docker" \ org.opencontainers.image.vendor="akkoma.dev" \
org.opencontainers.image.authors="ops@pleroma.social" \ org.opencontainers.image.documentation="https://docs.akkoma.dev/stable/" \
org.opencontainers.image.vendor="pleroma.social" \
org.opencontainers.image.documentation="https://git.pleroma.social/pleroma/pleroma" \
org.opencontainers.image.licenses="AGPL-3.0" \ 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.revision=$VCS_REF \
org.opencontainers.image.created=$BUILD_DATE org.opencontainers.image.created=$BUILD_DATE
ARG HOME=/opt/pleroma ARG HOME=/opt/akkoma
ARG DATA=/var/lib/pleroma ARG DATA=/var/lib/akkoma
RUN apk update &&\ RUN apk update &&\
apk add exiftool ffmpeg imagemagick libmagic ncurses postgresql-client &&\ 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}/uploads &&\
mkdir -p ${DATA}/static &&\ mkdir -p ${DATA}/static &&\
chown -R pleroma ${DATA} &&\ chown -R akkoma ${DATA} &&\
mkdir -p /etc/pleroma &&\ mkdir -p /etc/akkoma &&\
chown -R pleroma /etc/pleroma 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} COPY ./docker-entrypoint.sh ${HOME}
EXPOSE 4000 EXPOSE 4000
ENTRYPOINT ["/opt/pleroma/docker-entrypoint.sh"] ENTRYPOINT ["/opt/akkoma/docker-entrypoint.sh"]