bump v1.19.0

Rework the dockerfile to build dpkg in a dedicated stage.
This simplifies the diff and hopefully reduce maintenance cost for
future versions.
This commit is contained in:
Greizgh 2021-02-12 12:15:19 +01:00
parent 069766d714
commit 0a9bf0bf57
4 changed files with 41 additions and 153 deletions

View File

@ -71,7 +71,9 @@ elif [ "$DB_TYPE" = "postgresql" ]; then
fi fi
echo "[INFO] docker build -t bitwarden-deb "$DIR" --build-arg DB=$DB_TYPE" echo "[INFO] docker build -t bitwarden-deb "$DIR" --build-arg DB=$DB_TYPE"
docker build -t bitwarden-deb "$DIR" --build-arg DB=$DB_TYPE cp -r "$DIR/debian" "$SRC/debian"
docker build -t bitwarden-deb "$SRC" --build-arg DB=$DB_TYPE --target dpkg -f "$DIR/Dockerfile"
pushd "$SRC"; git clean -fd; popd
CID=$(docker run -d bitwarden-deb) CID=$(docker run -d bitwarden-deb)
docker cp "$CID":/bitwarden_package/bitwarden-rs.deb "$DST/bitwarden_rs-${OS_VERSION_NAME}-${REF}-${DB_TYPE}-${ARCH_DIR}.deb" docker cp "$CID":/bitwarden_package/bitwarden-rs.deb "$DST/bitwarden_rs-${OS_VERSION_NAME}-${REF}-${DB_TYPE}-${ARCH_DIR}.deb"

View File

@ -1,79 +1,26 @@
--- git/docker/amd64/Dockerfile 2020-12-29 21:18:53.687097820 +0100 --- git/docker/amd64/Dockerfile 2021-02-12 11:45:13.762372371 +0100
+++ Dockerfile 2020-12-29 21:50:52.627961467 +0100 +++ Dockerfile 2021-02-12 11:59:56.727518522 +0100
@@ -41,9 +41,9 @@ @@ -111,3 +111,23 @@
WORKDIR /app WORKDIR /
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
# Copies over *only* your manifests and build files CMD ["/start.sh"]
-COPY ./Cargo.* ./ +
-COPY ./rust-toolchain ./rust-toolchain +####################### dpkg target ##########################
-COPY ./build.rs ./build.rs +FROM build as dpkg
+COPY git/Cargo.* ./
+COPY git/rust-toolchain ./rust-toolchain
+COPY git/build.rs ./build.rs
# Builds your dependencies and removes the
@@ -54,7 +54,7 @@
# Copies the complete project
# To avoid copying unneeded files, use .dockerignore
-COPY . .
+COPY git .
# Make sure that we actually build the project
RUN touch src/main.rs
@@ -68,38 +68,22 @@
# because we already have a binary built
FROM debian:buster-slim
-ENV ROCKET_ENV "staging"
-ENV ROCKET_PORT=80
-ENV ROCKET_WORKERS=10
-
-# Install needed libraries
-RUN apt-get update && apt-get install -y \
- --no-install-recommends \
- openssl \
- ca-certificates \
- curl \
- sqlite3 \
- libmariadb-dev-compat \
- libpq5 \
- && rm -rf /var/lib/apt/lists/*
-
-RUN mkdir /data
-VOLUME /data
-EXPOSE 80
-EXPOSE 3012
-
-# Copies the files from the context (Rocket.toml file and web-vault)
-# and the binary from the "build" stage to the current stage
-COPY Rocket.toml .
-COPY --from=vault /web-vault ./web-vault
-COPY --from=build /app/target/release/bitwarden_rs .
-
-COPY docker/healthcheck.sh /healthcheck.sh
-COPY docker/start.sh /start.sh
+RUN mkdir -p /bitwarden_package/DEBIAN +RUN mkdir -p /bitwarden_package/DEBIAN
+RUN mkdir -p /bitwarden_package/usr/local/bin +RUN mkdir -p /bitwarden_package/usr/local/bin
+RUN mkdir -p /bitwarden_package/usr/lib/systemd/system +RUN mkdir -p /bitwarden_package/usr/lib/systemd/system
+RUN mkdir -p /bitwarden_package/etc/bitwarden_rs +RUN mkdir -p /bitwarden_package/etc/bitwarden_rs
+RUN mkdir -p /bitwarden_package/usr/share/bitwarden_rs +RUN mkdir -p /bitwarden_package/usr/share/bitwarden_rs
+
-HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"]
+WORKDIR /bitwarden_package +WORKDIR /bitwarden_package
-# Configures the startup!
-WORKDIR /
-CMD ["/start.sh"]
+COPY debian/control /bitwarden_package/DEBIAN/control +COPY debian/control /bitwarden_package/DEBIAN/control
+COPY debian/postinst /bitwarden_package/DEBIAN/postinst +COPY debian/postinst /bitwarden_package/DEBIAN/postinst
+COPY debian/conffiles /bitwarden_package/DEBIAN/conffiles +COPY debian/conffiles /bitwarden_package/DEBIAN/conffiles
+COPY git/Rocket.toml /bitwarden_package/etc/bitwarden_rs +COPY Rocket.toml /bitwarden_package/etc/bitwarden_rs
+COPY debian/config.env /bitwarden_package/etc/bitwarden_rs +COPY debian/config.env /bitwarden_package/etc/bitwarden_rs
+COPY debian/bitwarden_rs.service /bitwarden_package/usr/lib/systemd/system +COPY debian/bitwarden_rs.service /bitwarden_package/usr/lib/systemd/system
+COPY --from=vault /web-vault /bitwarden_package/usr/share/bitwarden_rs/web-vault +COPY --from=vault /web-vault /bitwarden_package/usr/share/bitwarden_rs/web-vault
+COPY --from=build app/target/release/bitwarden_rs /bitwarden_package/usr/local/bin +COPY --from=build app/target/release/bitwarden_rs /bitwarden_package/usr/local/bin
+
+# Create the package
+RUN dpkg-deb --build . bitwarden-rs.deb +RUN dpkg-deb --build . bitwarden-rs.deb

View File

@ -1,87 +0,0 @@
--- git/docker/arm32v7/Dockerfile 2020-12-29 21:18:53.687097820 +0100
+++ Dockerfile.arm 2020-12-29 21:59:53.090210238 +0100
@@ -61,9 +61,9 @@
WORKDIR /app
# Copies over *only* your manifests and build files
-COPY ./Cargo.* ./
-COPY ./rust-toolchain ./rust-toolchain
-COPY ./build.rs ./build.rs
+COPY git/Cargo.* ./
+COPY git/rust-toolchain ./rust-toolchain
+COPY git/build.rs ./build.rs
# NOTE: This should be the last apt-get/dpkg for this stage, since after this it will fail because of broken dependencies.
# For Diesel-RS migrations_macros to compile with MySQL/MariaDB we need to do some magic.
@@ -95,7 +95,7 @@
# Copies the complete project
# To avoid copying unneeded files, use .dockerignore
-COPY . .
+COPY git .
# Make sure that we actually build the project
RUN touch src/main.rs
@@ -107,45 +107,24 @@
######################## RUNTIME IMAGE ########################
# Create a new stage with a minimal image
# because we already have a binary built
-FROM balenalib/armv7hf-debian:buster
-
-ENV ROCKET_ENV "staging"
-ENV ROCKET_PORT=80
-ENV ROCKET_WORKERS=10
-
-RUN [ "cross-build-start" ]
-
-# Install needed libraries
-RUN apt-get update && apt-get install -y \
- --no-install-recommends \
- openssl \
- ca-certificates \
- curl \
- sqlite3 \
- libmariadb-dev-compat \
- libpq5 \
- && rm -rf /var/lib/apt/lists/*
-
-RUN mkdir /data
-
-RUN [ "cross-build-end" ]
-
-VOLUME /data
-EXPOSE 80
-EXPOSE 3012
-
-# Copies the files from the context (Rocket.toml file and web-vault)
-# and the binary from the "build" stage to the current stage
-COPY Rocket.toml .
-COPY --from=vault /web-vault ./web-vault
-COPY --from=build /app/target/armv7-unknown-linux-gnueabihf/release/bitwarden_rs .
+FROM debian:buster-slim
-COPY docker/healthcheck.sh /healthcheck.sh
-COPY docker/start.sh /start.sh
+RUN mkdir -p /bitwarden_package/DEBIAN
+RUN mkdir -p /bitwarden_package/usr/local/bin
+RUN mkdir -p /bitwarden_package/usr/lib/systemd/system
+RUN mkdir -p /bitwarden_package/etc/bitwarden_rs
+RUN mkdir -p /bitwarden_package/usr/share/bitwarden_rs
-HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"]
+WORKDIR /bitwarden_package
-# Configures the startup!
-WORKDIR /
-CMD ["/start.sh"]
+COPY debian/control /bitwarden_package/DEBIAN/control
+COPY debian/postinst /bitwarden_package/DEBIAN/postinst
+COPY debian/conffiles /bitwarden_package/DEBIAN/conffiles
+COPY git/Rocket.toml /bitwarden_package/etc/bitwarden_rs
+COPY debian/config.env /bitwarden_package/etc/bitwarden_rs
+COPY debian/bitwarden_rs.service /bitwarden_package/usr/lib/systemd/system
+COPY --from=vault /web-vault /bitwarden_package/usr/share/bitwarden_rs/web-vault
+COPY --from=build app/target/armv7-unknown-linux-gnueabihf/release/bitwarden_rs /bitwarden_package/usr/local/bin
+# Create the package
+RUN dpkg-deb --build . bitwarden-rs.deb

View File

@ -0,0 +1,26 @@
--- git/docker/armv7/Dockerfile 2021-02-12 11:45:13.763372371 +0100
+++ Dockerfile 2021-02-12 12:25:50.078877369 +0100
@@ -157,3 +157,23 @@
WORKDIR /
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["/start.sh"]
+
+####################### dpkg target ##########################
+FROM build as dpkg
+RUN mkdir -p /bitwarden_package/DEBIAN
+RUN mkdir -p /bitwarden_package/usr/local/bin
+RUN mkdir -p /bitwarden_package/usr/lib/systemd/system
+RUN mkdir -p /bitwarden_package/etc/bitwarden_rs
+RUN mkdir -p /bitwarden_package/usr/share/bitwarden_rs
+
+WORKDIR /bitwarden_package
+COPY debian/control /bitwarden_package/DEBIAN/control
+COPY debian/postinst /bitwarden_package/DEBIAN/postinst
+COPY debian/conffiles /bitwarden_package/DEBIAN/conffiles
+COPY Rocket.toml /bitwarden_package/etc/bitwarden_rs
+COPY debian/config.env /bitwarden_package/etc/bitwarden_rs
+COPY debian/bitwarden_rs.service /bitwarden_package/usr/lib/systemd/system
+COPY --from=vault /web-vault /bitwarden_package/usr/share/bitwarden_rs/web-vault
+COPY --from=build app/target/armv7-unknown-linux-gnueabihf/release/bitwarden_rs /bitwarden_package/usr/local/bin
+
+RUN dpkg-deb --build . bitwarden-rs.deb