]> Untitled Git - lemmy.git/commitdiff
Updating rust musl images
authorDessalines <tyhou13@gmx.com>
Tue, 9 Nov 2021 22:16:59 +0000 (17:16 -0500)
committerDessalines <tyhou13@gmx.com>
Tue, 9 Nov 2021 22:16:59 +0000 (17:16 -0500)
.drone.yml
docker/dev/Dockerfile
docker/prod/Dockerfile

index a4e44b3387dcc209130553cc3cb16cb17d0bf4c7..87f123b1bf73a344a3f45a105127ff60a931c462 100644 (file)
@@ -9,7 +9,7 @@ platform:
 steps:
 
   - name: prepare repo
-    image: ekidd/rust-musl-builder:1.51.0
+    image: clux/muslrust:1.56.0
     user: root
     commands:
       - chown 1000:1000 . -R
@@ -21,31 +21,32 @@ steps:
       - /root/.cargo/bin/cargo fmt -- --check
 
   - name: cargo clippy
-    image: ekidd/rust-musl-builder:1.51.0
+    image: clux/muslrust:1.56.0
     commands:
+      - rustup component add clippy
       - cargo clippy --workspace --tests --all-targets --all-features -- -D warnings -D deprecated -D clippy::perf -D clippy::complexity -D clippy::dbg_macro
       - cargo clippy --workspace -- -D clippy::unwrap_used
 
   - name: cargo test
-    image: ekidd/rust-musl-builder:1.51.0
+    image: clux/muslrust:1.56.0
     environment:
       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
       LEMMY_CONFIG_LOCATION: ../../config/config.hjson
       RUST_BACKTRACE: 1
       RUST_TEST_THREADS: 1
     commands:
-      - sudo apt-get update
-      - sudo apt-get -y install --no-install-recommends postgresql-client
+      - apt-get update
+      - apt-get -y install --no-install-recommends postgresql-client
       - cargo test --workspace --no-fail-fast
 
   - name: check defaults.hjson updated
-    image: ekidd/rust-musl-builder:1.51.0
+    image: clux/muslrust:1.56.0
     commands:
       - ./scripts/update_config_defaults.sh config/defaults_current.hjson
       - diff config/defaults.hjson config/defaults_current.hjson
 
   - name: cargo build
-    image: ekidd/rust-musl-builder:1.51.0
+    image: clux/muslrust:1.56.0
     commands:
       - cargo build
       - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
@@ -129,7 +130,7 @@ steps:
   - name: prepare repo
     # Not sure why, but rust ARM64 builds are failing on drone for rust:1.54 and later:
     # https://discourse.drone.io/t/arm-build-stalls-out-on-cloud-drone-io-ram-issue/9701
-    image: rust:1.51-slim
+    image: rust:1.56-slim
     user: root
     commands:
       - chown 1000:1000 . -R
@@ -138,7 +139,7 @@ steps:
       - git fetch --tags
 
   - name: cargo test
-    image: rust:1.51-slim
+    image: rust:1.56-slim
     environment:
       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
       LEMMY_CONFIG_LOCATION: ../../config/config.hjson
@@ -152,7 +153,7 @@ steps:
 
   # Using Debian here because there seems to be no official Alpine-based Rust docker image for ARM.
   - name: cargo build
-    image: rust:1.51-slim
+    image: rust:1.56-slim
     commands:
       - apt-get update
       - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
index 732f9068dee5b61716bbc0bdd06797943946ec15..95329c0154eba730002cac27bc180bf9db146f80 100644 (file)
@@ -1,43 +1,31 @@
-ARG RUST_BUILDER_IMAGE=ekidd/rust-musl-builder:1.51.0
+ARG RUST_BUILDER_IMAGE=clux/muslrust:1.56.0
 
-# Cargo chef plan
-FROM $RUST_BUILDER_IMAGE as planner
-WORKDIR /app
+FROM $RUST_BUILDER_IMAGE as chef
+USER root
 RUN cargo install cargo-chef
+WORKDIR /app
+
+# Cargo chef plan
+FROM chef as planner
 
 # Copy dirs
-COPY ./ ./
+COPY . .
 
-RUN sudo chown -R rust:rust .
 RUN cargo chef prepare --recipe-path recipe.json
 
-# Cargo chef cache dependencies
-FROM $RUST_BUILDER_IMAGE as cacher
-ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
-WORKDIR /app
-RUN cargo install cargo-chef
-COPY --from=planner /app/recipe.json ./recipe.json
-RUN sudo chown -R rust:rust .
-RUN cargo chef cook --target ${CARGO_BUILD_TARGET} --recipe-path recipe.json
-
-# Build the project
-FROM $RUST_BUILDER_IMAGE as builder
-
+FROM chef as builder
 ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
 ARG RUSTRELEASEDIR="debug"
 
-WORKDIR /app
-
-# Copy over the cached dependencies
-COPY --from=cacher /app/target target
-COPY --from=cacher /home/rust/.cargo /home/rust/.cargo
+COPY --from=planner /app/recipe.json ./recipe.json
+RUN cargo chef cook --recipe-path recipe.json --target ${CARGO_BUILD_TARGET}
 
 # Copy the rest of the dirs
-COPY ./ ./
+COPY . .
 
-RUN sudo chown -R rust:rust .
+# Build the project
 RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"
-RUN cargo build
+RUN cargo build --target ${CARGO_BUILD_TARGET}
 
 # reduce binary size
 RUN strip ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server
@@ -50,13 +38,8 @@ FROM alpine:3 as lemmy
 # Install libpq for postgres
 RUN apk add libpq
 
-RUN addgroup -g 1000 lemmy
-RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
-
 # Copy resources
-COPY --chown=lemmy:lemmy --from=builder /app/lemmy_server /app/lemmy
+COPY --from=builder /app/lemmy_server /app/lemmy
 
-RUN chown lemmy:lemmy /app/lemmy
-USER lemmy
 EXPOSE 8536
 CMD ["/app/lemmy"]
index 2f3d278a92c55f82fb0aeee2522b2251e4e29968..7257e868b9198b310a834ec8041388c2b7cd03d5 100644 (file)
@@ -1,5 +1,5 @@
 # Build the project
-FROM ekidd/rust-musl-builder:1.51.0 as builder
+FROM clux/muslrust:1.56.0 as builder
 
 ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
 ARG RUSTRELEASEDIR="release"
@@ -8,7 +8,6 @@ WORKDIR /app
 
 COPY ./ ./
 
-RUN sudo chown -R rust:rust .
 RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"
 RUN cargo build --release
 
@@ -23,13 +22,8 @@ FROM alpine:3 as lemmy
 # Install libpq for postgres
 RUN apk add libpq
 
-RUN addgroup -g 1000 lemmy
-RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
-
 # Copy resources
-COPY --chown=lemmy:lemmy --from=builder /app/lemmy_server /app/lemmy
+COPY --from=builder /app/lemmy_server /app/lemmy
 
-RUN chown lemmy:lemmy /app/lemmy
-USER lemmy
 EXPOSE 8536
 CMD ["/app/lemmy"]