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,7 +1,6 @@
# build folders and similar which are not needed for the docker build # build folders and similar which are not needed for the docker build
target target
docker docker
!docker/builders/lemmy-builder-arm64/docker-build.sh
api_tests api_tests
ansible ansible
tests tests

View file

@ -227,19 +227,6 @@ steps:
- event: push - event: push
branch: main 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: publish_release_docker:
image: woodpeckerci/plugin-docker-buildx image: woodpeckerci/plugin-docker-buildx
secrets: [docker_username, docker_password] secrets: [docker_username, docker_password]
@ -249,7 +236,6 @@ steps:
platforms: linux/amd64, linux/arm64 platforms: linux/amd64, linux/arm64
build_args: build_args:
- RUST_RELEASE_MODE=release - RUST_RELEASE_MODE=release
- LEMMY_VERSION=${CI_COMMIT_TAG}
tag: ${CI_COMMIT_TAG} tag: ${CI_COMMIT_TAG}
when: when:
event: tag event: tag

View file

@ -2,10 +2,9 @@
ARG RUST_VERSION=1.72.1 ARG RUST_VERSION=1.72.1
ARG CARGO_BUILD_FEATURES=default ARG CARGO_BUILD_FEATURES=default
ARG RUST_RELEASE_MODE=debug ARG RUST_RELEASE_MODE=debug
ARG LEMMY_VERSION="dev"
ARG AMD_BUILDER_IMAGE=rust:${RUST_VERSION} 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 AMD_RUNNER_IMAGE=debian:bookworm-slim
ARG ARM_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 \ if [ "${RUST_RELEASE_MODE}" = "debug" ]; then \
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \ echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \
cargo build --features "${CARGO_BUILD_FEATURES}"; \ cargo build --features "${CARGO_BUILD_FEATURES}"; \
mv target/debug/lemmy_server ./lemmy; \ mv target/"${RUST_RELEASE_MODE}"/lemmy_server ./lemmy_server; \
fi fi
# Release build # Release build
RUN set -ex; \ RUN --mount=type=cache,target=/lemmy/target set -ex; \
if [ "${RUST_RELEASE_MODE}" = "release" ]; then \ if [ "${RUST_RELEASE_MODE}" = "release" ]; then \
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \ 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; \ cargo build --features "${CARGO_BUILD_FEATURES}" --release; \
mv target/release/lemmy_server ./lemmy; \ mv target/"${RUST_RELEASE_MODE}"/lemmy_server ./lemmy_server; \
fi fi
# ARM64 builder # ARM64 builder
@ -45,13 +45,42 @@ RUN set -ex; \
# seem to be expended in --form arg of COPY :( # seem to be expended in --form arg of COPY :(
FROM --platform=linux/amd64 ${ARM_BUILDER_IMAGE} AS build-arm64 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 # amd64 base runner
FROM ${AMD_RUNNER_IMAGE} AS runner-linux-amd64 FROM ${AMD_RUNNER_IMAGE} AS runner-linux-amd64
# Federation needs CA certificates # Federation needs CA certificates
RUN apt update && apt install -y libssl-dev libpq-dev 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 # arm base runner
FROM ${ARM_RUNNER_IMAGE} AS runner-linux-arm64 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