From: Nutomic <me@nutomic.com>
Date: Thu, 8 Apr 2021 14:33:58 +0000 (+0000)
Subject: Drone release main (ref #1556) (#1557)
X-Git-Url: http://these/git/%22https:/image.com/%24%7Bargs.pageFn.prev%7D?a=commitdiff_plain;h=b8a6592369e0704812478574ed207e9aedf32b64;p=lemmy.git

Drone release main (ref #1556) (#1557)

* publish docker images from main

* try with separate step

* redo, lots of boilerplate

* try to fix syntax

* unique step names

* fix docker tags, remove cargo-chef

* only build dev image on main branch

* use `ref` for condition, as `branch` uses the target branch for PRs

* consistent indents

* fix tag

* use lemmy-ui:dev image for `docker/dev` and `docker/federation`
---

diff --git a/.drone.yml b/.drone.yml
index 7dd4d3e7..18db1fad 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -55,7 +55,39 @@ steps:
       - yarn
       - yarn api-test
 
-  - name: make release build and push to docker hub
+  - name: publish dev docker image
+    image: plugins/docker
+    settings:
+      dockerfile: docker/prod/Dockerfile
+      username:
+        from_secret: docker_username
+      password:
+        from_secret: docker_password
+      repo: dessalines/lemmy
+      tags:
+        - dev-linux-amd64
+    when:
+      ref:
+        - refs/heads/main
+
+  - name: publish dev docker manifest
+    image: plugins/manifest
+    settings:
+      username:
+        from_secret: docker_username
+      password:
+        from_secret: docker_password
+      target: "dessalines/lemmy:dev"
+      template: "dessalines/lemmy:dev-OS-ARCH"
+      platforms:
+        - linux/amd64
+        - linux/arm64
+      ignore_missing: true
+    when:
+      ref:
+        - refs/heads/main
+
+  - name: publish release docker image
     image: plugins/docker
     settings:
       dockerfile: docker/prod/Dockerfile
@@ -68,9 +100,9 @@ steps:
       auto_tag_suffix: linux-amd64
     when:
       ref:
-      - refs/tags/*
+        - refs/tags/*
 
-  - name: push to docker manifest
+  - name: publish release docker manifest
     image: plugins/manifest
     settings: 
       username:
@@ -85,7 +117,7 @@ steps:
       ignore_missing: true
     when:
       ref:
-      - refs/tags/*
+        - refs/tags/*
 
 services:
   - name: database
@@ -140,7 +172,39 @@ steps:
       - yarn
       - yarn api-test
 
-  - name: make release build and push to docker hub
+  - name: publish dev docker image
+    image: plugins/docker
+    settings:
+      dockerfile: docker/prod/Dockerfile.arm
+      username:
+        from_secret: docker_username
+      password:
+        from_secret: docker_password
+      repo: dessalines/lemmy
+      tags:
+        - dev-linux-arm64
+    when:
+      ref:
+        - refs/heads/main
+
+  - name: publish dev docker manifest
+    image: plugins/manifest
+    settings:
+      username:
+        from_secret: docker_username
+      password:
+        from_secret: docker_password
+      target: "dessalines/lemmy:dev"
+      template: "dessalines/lemmy:dev-OS-ARCH"
+      platforms:
+        - linux/amd64
+        - linux/arm64
+      ignore_missing: true
+    when:
+      ref:
+        - refs/heads/main
+
+  - name: publish release docker image
     image: plugins/docker
     settings:
       dockerfile: docker/prod/Dockerfile.arm
@@ -155,7 +219,7 @@ steps:
       ref:
         - refs/tags/*
 
-  - name: push to docker manifest
+  - name: publish release docker manifest
     image: plugins/manifest
     settings: 
       username:
@@ -170,7 +234,7 @@ steps:
       ignore_missing: true
     when:
       ref:
-      - refs/tags/*
+        - refs/tags/*
 
 services:
   - name: database
diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml
index 5661ce55..7f8979fe 100644
--- a/docker/dev/docker-compose.yml
+++ b/docker/dev/docker-compose.yml
@@ -17,7 +17,7 @@ services:
       - iframely
 
   lemmy-ui:
-    image: dessalines/lemmy-ui:0.10.3
+    image: dessalines/lemmy-ui:dev
     ports:
       - "1235:1234"
     restart: always
diff --git a/docker/dev/docker_update.sh b/docker/dev/docker_update.sh
index 4531a1bd..9623d4dc 100755
--- a/docker/dev/docker_update.sh
+++ b/docker/dev/docker_update.sh
@@ -8,4 +8,5 @@ set -e
 mkdir -p volumes/pictrs
 sudo chown -R 991:991 volumes/pictrs
 sudo docker build ../../ --file ../dev/Dockerfile -t lemmy-dev:latest
+sudo docker-compose pull --ignore-pull-failures || true
 sudo docker-compose up -d
diff --git a/docker/dev/docker_update_volume_mount.sh b/docker/dev/docker_update_volume_mount.sh
index bc4f832f..7fbd212a 100755
--- a/docker/dev/docker_update_volume_mount.sh
+++ b/docker/dev/docker_update_volume_mount.sh
@@ -8,4 +8,5 @@ set -e
 mkdir -p volumes/pictrs
 sudo chown -R 991:991 volumes/pictrs
 sudo docker build ../../ --file ../dev/volume_mount.dockerfile -t lemmy-dev:latest
+sudo docker-compose pull --ignore-pull-failures || true
 sudo docker-compose up
diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml
index 74b84e2d..c13c89ea 100644
--- a/docker/federation/docker-compose.yml
+++ b/docker/federation/docker-compose.yml
@@ -29,7 +29,7 @@ services:
       - ./volumes/pictrs_alpha:/mnt
 
   lemmy-alpha-ui:
-    image: dessalines/lemmy-ui:0.10.3
+    image: dessalines/lemmy-ui:dev
     environment:
       - LEMMY_INTERNAL_HOST=lemmy-alpha:8541
       - LEMMY_EXTERNAL_HOST=localhost:8541
@@ -58,7 +58,7 @@ services:
       - ./volumes/postgres_alpha:/var/lib/postgresql/data
 
   lemmy-beta-ui:
-    image: dessalines/lemmy-ui:0.10.3
+    image: dessalines/lemmy-ui:dev
     environment:
       - LEMMY_INTERNAL_HOST=lemmy-beta:8551
       - LEMMY_EXTERNAL_HOST=localhost:8551
@@ -87,7 +87,7 @@ services:
       - ./volumes/postgres_beta:/var/lib/postgresql/data
 
   lemmy-gamma-ui:
-    image: dessalines/lemmy-ui:0.10.3
+    image: dessalines/lemmy-ui:dev
     environment:
       - LEMMY_INTERNAL_HOST=lemmy-gamma:8561
       - LEMMY_EXTERNAL_HOST=localhost:8561
@@ -117,7 +117,7 @@ services:
 
   # An instance with only an allowlist for beta
   lemmy-delta-ui:
-    image: dessalines/lemmy-ui:0.10.3
+    image: dessalines/lemmy-ui:dev
     environment:
       - LEMMY_INTERNAL_HOST=lemmy-delta:8571
       - LEMMY_EXTERNAL_HOST=localhost:8571
@@ -147,7 +147,7 @@ services:
 
   # An instance who has a blocklist, with lemmy-alpha blocked
   lemmy-epsilon-ui:
-    image: dessalines/lemmy-ui:0.10.3
+    image: dessalines/lemmy-ui:dev
     environment:
       - LEMMY_INTERNAL_HOST=lemmy-epsilon:8581
       - LEMMY_EXTERNAL_HOST=localhost:8581
diff --git a/docker/federation/start-local-instances.bash b/docker/federation/start-local-instances.bash
index e963792a..74f629e9 100755
--- a/docker/federation/start-local-instances.bash
+++ b/docker/federation/start-local-instances.bash
@@ -8,4 +8,5 @@ for Item in alpha beta gamma delta epsilon ; do
   sudo chown -R 991:991 volumes/pictrs_$Item
 done
 
+sudo docker-compose pull --ignore-pull-failures || true
 sudo docker-compose up
diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile
index 88a05fb2..75c53e67 100644
--- a/docker/prod/Dockerfile
+++ b/docker/prod/Dockerfile
@@ -1,38 +1,11 @@
-ARG RUST_BUILDER_IMAGE=ekidd/rust-musl-builder:1.50.0
-
-# Cargo chef plan
-FROM $RUST_BUILDER_IMAGE as planner
-WORKDIR /app
-RUN cargo install cargo-chef
-
-# Copy dirs
-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 --release --target ${CARGO_BUILD_TARGET} --recipe-path recipe.json
-
 # Build the project
-FROM $RUST_BUILDER_IMAGE as builder
+FROM ekidd/rust-musl-builder:1.50.0 as builder
 
 ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
 ARG RUSTRELEASEDIR="release"
 
 WORKDIR /app
 
-# Copy over the cached dependencies
-COPY --from=cacher /app/target target
-COPY --from=cacher /home/rust/.cargo /home/rust/.cargo
-
-# Copy the rest of the dirs
 COPY ./ ./
 
 RUN sudo chown -R rust:rust .
diff --git a/docker/prod/deploy.sh b/docker/prod/deploy.sh
index b2ee1663..7520f149 100755
--- a/docker/prod/deploy.sh
+++ b/docker/prod/deploy.sh
@@ -12,14 +12,6 @@ echo "pub const VERSION: &str = \"$new_tag\";" > "crates/utils/src/version.rs"
 git add "crates/utils/src/version.rs"
 popd
 
-# Changing various references to the Lemmy version
-sed -i "s/dessalines\/lemmy:.*/dessalines\/lemmy:$new_tag/" ../dev/docker-compose.yml
-sed -i "s/dessalines\/lemmy-ui:.*/dessalines\/lemmy-ui:$new_tag/" ../dev/docker-compose.yml
-sed -i "s/dessalines\/lemmy:.*/dessalines\/lemmy:$new_tag/" ../federation/docker-compose.yml
-sed -i "s/dessalines\/lemmy-ui:.*/dessalines\/lemmy-ui:$new_tag/" ../federation/docker-compose.yml
-git add ../dev/docker-compose.yml
-git add ../federation/docker-compose.yml
-
 # The ansible and docker installs should only update for non release-candidates
 # IE, when the third semver is a number, not '2-rc'
 if [ ! -z "${third_semver##*[!0-9]*}" ]; then