Fix entrypoint in Dockerfile (#4202)

* Fix entrypoint

* Delete docker/builders/lemmy-builder-arm64/docker-build.sh

* Delete docker/builders directory

* Remove exception for builder

* Remove publish_builder_arm64
This commit is contained in:
Kroese 2023-11-26 22:50:31 +01:00 committed by GitHub
parent 8a05c8f8be
commit fc07ba2d3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 65 deletions

View File

@ -1,9 +1,8 @@
# build folders and similar which are not needed for the docker build
target
docker
!docker/builders/lemmy-builder-arm64/docker-build.sh
api_tests
ansible
tests
*.sh
pictrs
pictrs

View File

@ -227,19 +227,6 @@ steps:
- event: push
branch: main
publish_builder_arm64:
image: woodpeckerci/plugin-docker-buildx
secrets: [docker_username, docker_password]
settings:
repo: dessalines/lemmy-builder-arm64
dockerfile: docker/builders/lemmy-builder-arm64/Dockerfile
platforms: linux/amd64
build_args:
- RUST_RELEASE_MODE=release
tag: ${CI_COMMIT_TAG}
when:
event: tag
publish_release_docker:
image: woodpeckerci/plugin-docker-buildx
secrets: [docker_username, docker_password]
@ -249,7 +236,6 @@ steps:
platforms: linux/amd64, linux/arm64
build_args:
- RUST_RELEASE_MODE=release
- LEMMY_VERSION=${CI_COMMIT_TAG}
tag: ${CI_COMMIT_TAG}
when:
event: tag

View File

@ -2,10 +2,9 @@
ARG RUST_VERSION=1.72.1
ARG CARGO_BUILD_FEATURES=default
ARG RUST_RELEASE_MODE=debug
ARG LEMMY_VERSION="dev"
ARG AMD_BUILDER_IMAGE=rust:${RUST_VERSION}
ARG ARM_BUILDER_IMAGE="dessalines/lemmy-builder-arm64:${LEMMY_VERSION}"
ARG ARM_BUILDER_IMAGE="ghcr.io/raskyld/aarch64-lemmy-linux-gnu:v0.1.0"
ARG AMD_RUNNER_IMAGE=debian:bookworm-slim
ARG ARM_RUNNER_IMAGE=debian:bookworm-slim
@ -29,15 +28,16 @@ RUN --mount=type=cache,target=/lemmy/target set -ex; \
if [ "${RUST_RELEASE_MODE}" = "debug" ]; then \
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \
cargo build --features "${CARGO_BUILD_FEATURES}"; \
mv target/debug/lemmy_server ./lemmy; \
mv target/"${RUST_RELEASE_MODE}"/lemmy_server ./lemmy_server; \
fi
# Release build
RUN set -ex; \
RUN --mount=type=cache,target=/lemmy/target set -ex; \
if [ "${RUST_RELEASE_MODE}" = "release" ]; then \
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \
[ -z "$USE_RELEASE_CACHE" ] && cargo clean --release; \
cargo build --features "${CARGO_BUILD_FEATURES}" --release; \
mv target/release/lemmy_server ./lemmy; \
mv target/"${RUST_RELEASE_MODE}"/lemmy_server ./lemmy_server; \
fi
# ARM64 builder
@ -45,13 +45,42 @@ RUN set -ex; \
# seem to be expended in --form arg of COPY :(
FROM --platform=linux/amd64 ${ARM_BUILDER_IMAGE} AS build-arm64
ARG RUST_RELEASE_MODE
ARG CARGO_BUILD_FEATURES
WORKDIR /home/lemmy/src
USER 10001:10001
COPY --chown=lemmy:lemmy . ./
ENV PATH="/home/lemmy/.cargo/bin:${PATH}"
ENV RUST_RELEASE_MODE=${RUST_RELEASE_MODE} \
CARGO_BUILD_FEATURES=${CARGO_BUILD_FEATURES}
# Debug build
RUN --mount=type=cache,target=./target,uid=10001,gid=10001 set -ex; \
if [ "${RUST_RELEASE_MODE}" = "debug" ]; then \
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \
cargo build --features "${CARGO_BUILD_FEATURES}"; \
mv "./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server" /home/lemmy/lemmy_server; \
fi
# Release build
RUN --mount=type=cache,target=./target,uid=10001,gid=10001 set -ex; \
if [ "${RUST_RELEASE_MODE}" = "release" ]; then \
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \
[ -z "$USE_RELEASE_CACHE" ] && cargo clean --release; \
cargo build --features "${CARGO_BUILD_FEATURES}" --release; \
mv "./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server" /home/lemmy/lemmy_server; \
fi
# amd64 base runner
FROM ${AMD_RUNNER_IMAGE} AS runner-linux-amd64
# Federation needs CA certificates
RUN apt update && apt install -y libssl-dev libpq-dev ca-certificates
COPY --from=build-amd64 --chmod=0755 /lemmy/lemmy /usr/local/bin
COPY --from=build-amd64 --chmod=0755 /lemmy/lemmy_server /usr/local/bin
# arm base runner
FROM ${ARM_RUNNER_IMAGE} AS runner-linux-arm64

View File

@ -1,23 +0,0 @@
ARG ARM_CROSS_TOOLCHAIN="ghcr.io/raskyld/aarch64-lemmy-linux-gnu:v0.1.0"
FROM ${ARM_CROSS_TOOLCHAIN}
# NB(raskyld): Please, do not hesitate to contact me through @raskyld@social.vivaldi.net (mastodon)
# If you have any question about the cross-toolchain
LABEL org.opencontainers.image.authors="Enzo Nocera <enzo@nocera.eu>"
LABEL org.opencontainers.image.source="https://github.com/LemmyNet/lemmy"
LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later"
LABEL org.opencontainers.image.description="A prebuilt lemmy server using a cross toolchain from amd64 to aarch64/arm64"
ARG CARGO_BUILD_FEATURES=default
ARG RUST_RELEASE_MODE=debug
WORKDIR /home/lemmy/src
USER 10001:10001
COPY --chown=lemmy:lemmy . ./
ENV RUST_RELEASE_MODE=${RUST_RELEASE_MODE} \
CARGO_BUILD_FEATURES=${CARGO_BUILD_FEATURES}
RUN --mount=type=cache,target=./target,uid=10001,gid=10001 bash ./docker/builders/lemmy-builder-arm64/docker-build.sh

View File

@ -1,20 +0,0 @@
#!/usr/bin/env bash
set -e;
source "$HOME/.cargo/env"
case "$RUST_RELEASE_MODE" in
"debug")
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"
cargo build --features "${CARGO_BUILD_FEATURES}"
cp "./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server" /home/lemmy/lemmy_server
;;
"release")
# Pass a value to $USE_RELEASE_CACHE to avoid purging the cache for release builds
[[ -z "$USE_RELEASE_CACHE" ]] || cargo clean --release
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"
cargo build --features "${CARGO_BUILD_FEATURES}" --release
cp "./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server" /home/lemmy/lemmy_server
;;
esac