Update Dockerfile (#28)

* Try to make it impossible to confuse arches

* Use GHA cache
This commit is contained in:
Jordan Webb 2022-05-01 23:06:58 -05:00 committed by GitHub
parent 6f627ddfca
commit bc7fbb716c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 15 deletions

View File

@ -14,7 +14,6 @@ name: Build
env:
CONTAINER_NAME: jordemort/pleroma:${{ github.event.inputs.container_tag || 'latest' }}
CACHE_NAME: jordemort/pleroma:cache-unzip
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
DOCKER_CLI_EXPERIMENTAL: enabled
@ -25,34 +24,34 @@ jobs:
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1.2.0
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1.7.0
uses: docker/setup-buildx-action@v1
- name: Login to container registry
uses: docker/login-action@v1.14.1
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- uses: actions/checkout@v3.0.2
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Pull cached containers
run: |
docker pull --platform "$PLATFORMS" --quiet "$CONTAINER_NAME" || true
docker pull --platform "$PLATFORMS" --quiet "$CACHE_NAME" || true
# Needed for buildx gha cache to work
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v1
- name: Build and push container
run: |
buildx_argv=(
--pull
--build-arg BUILDKIT_INLINE_CACHE=1
--platform "$PLATFORMS"
--cache-from "$CONTAINER_NAME"
--cache-from type=gha
--cache-to type=gha,mode=max
--tag "$CONTAINER_NAME"
)
@ -61,7 +60,6 @@ jobs:
fi
set -x
docker buildx build "${buildx_argv[@]}" --target unzip .
docker buildx build "${buildx_argv[@]}" .
- uses: sarisia/actions-status-discord@v1

View File

@ -14,9 +14,9 @@ ARG TARGETARCH
# from ADD left over in the final image.
ADD https://git.pleroma.social/api/v4/projects/2/jobs/artifacts/stable/download?job=${TARGETARCH} /tmp/pleroma.zip
RUN mkdir -p /opt/pleroma && \
RUN mkdir -p /opt/pleroma-${TARGETARCH} && \
unzip /tmp/pleroma.zip -d /tmp/ && \
mv /tmp/release/* /opt/pleroma
mv /tmp/release/* /opt/pleroma-${TARGETARCH}
# Ok, really build the container now
FROM ubuntu:20.04 AS pleroma
@ -41,7 +41,9 @@ RUN mkdir -p /etc/pleroma /var/lib/pleroma/static /var/lib/pleroma/uploads && \
adduser --system --shell /bin/false --home /opt/pleroma --group pleroma && \
chown -vR pleroma /etc/pleroma /var/lib/pleroma
COPY --chown=pleroma:pleroma --from=unzip /opt/pleroma/ /opt/pleroma/
ARG TARGETARCH
COPY --chown=pleroma:pleroma --from=unzip /opt/pleroma-${TARGETARCH}/ /opt/pleroma/
VOLUME [ "/etc/pleroma", "/var/lib/pleroma/uploads", "/var/lib/pleroma/static" ]