Refactor CI build (#80)
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/80
This commit is contained in:
parent
5b4d77eaa7
commit
ff16840cc8
|
@ -6,6 +6,12 @@ COPYING
|
|||
*file
|
||||
elixir_buildpack.config
|
||||
test/
|
||||
instance/
|
||||
_build
|
||||
deps
|
||||
test
|
||||
benchmarks
|
||||
docs/site
|
||||
|
||||
# Required to get version
|
||||
!.git
|
||||
|
|
|
@ -1,127 +1,58 @@
|
|||
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
|
||||
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 || 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
|
||||
|
|
38
Dockerfile
38
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"]
|
||||
|
|
Loading…
Reference in a new issue