aboutsummaryrefslogtreecommitdiff
path: root/docker/Dockerfile.debian
diff options
context:
space:
mode:
authorDaniel <[email protected]>2024-05-19 21:32:36 +0300
committerGitHub <[email protected]>2024-05-19 20:32:36 +0200
commit3261534438f572a36029f17f9a0ce88fe2b79b0d (patch)
tree94d7bd0cb9fe402d50f2646ea3697a5c59049990 /docker/Dockerfile.debian
parent46762d9fdeeb8e91c5e404a0a1a5f4399da45a05 (diff)
downloadvaultwarden-3261534438f572a36029f17f9a0ce88fe2b79b0d.tar.gz
vaultwarden-3261534438f572a36029f17f9a0ce88fe2b79b0d.zip
Optimize Dockerfiles (#4532)
Move some ARGs closer to the build stage (potentially improving caching) Remove redundant COPY commands Remove redundant RUN command Move CARGO_HOME's "&&" operator to the first line (improves consistency)
Diffstat (limited to 'docker/Dockerfile.debian')
-rw-r--r--docker/Dockerfile.debian31
1 files changed, 14 insertions, 17 deletions
diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian
index dc0d0a72..a9cf3b13 100644
--- a/docker/Dockerfile.debian
+++ b/docker/Dockerfile.debian
@@ -64,10 +64,7 @@ RUN apt-get update && \
"libc6-$(xx-info debian-arch)-cross" \
"libc6-dev-$(xx-info debian-arch)-cross" \
"linux-libc-dev-$(xx-info debian-arch)-cross" && \
- # Run xx-cargo early, since it sometimes seems to break when run at a later stage
- echo "export CARGO_TARGET=$(xx-cargo --print-target-triple)" >> /env-cargo
-
-RUN xx-apt-get install -y \
+ xx-apt-get install -y \
--no-install-recommends \
gcc \
libmariadb3 \
@@ -78,11 +75,13 @@ RUN xx-apt-get install -y \
# Force install arch dependend mariadb dev packages
# Installing them the normal way breaks several other packages (again)
apt-get download "libmariadb-dev-compat:$(xx-info debian-arch)" "libmariadb-dev:$(xx-info debian-arch)" && \
- dpkg --force-all -i ./libmariadb-dev*.deb
+ dpkg --force-all -i ./libmariadb-dev*.deb && \
+ # Run xx-cargo early, since it sometimes seems to break when run at a later stage
+ echo "export CARGO_TARGET=$(xx-cargo --print-target-triple)" >> /env-cargo
# Create CARGO_HOME folder and don't download rust docs
-RUN mkdir -pv "${CARGO_HOME}" \
- && rustup set profile minimal
+RUN mkdir -pv "${CARGO_HOME}" && \
+ rustup set profile minimal
# Creates a dummy project used to grab dependencies
RUN USER=root cargo new --bin /app
@@ -111,19 +110,16 @@ RUN source /env-cargo && \
# Output the current contents of the file
cat /env-cargo
-# Configure the DB ARG as late as possible to not invalidate the cached layers above
-ARG DB=sqlite,mysql,postgresql
-
RUN source /env-cargo && \
rustup target add "${CARGO_TARGET}"
+# Copies over *only* your manifests and build files
+COPY ./Cargo.* ./rust-toolchain.toml ./build.rs ./
+
ARG CARGO_PROFILE=release
-ARG VW_VERSION
-# Copies over *only* your manifests and build files
-COPY ./Cargo.* ./
-COPY ./rust-toolchain.toml ./rust-toolchain.toml
-COPY ./build.rs ./build.rs
+# Configure the DB ARG as late as possible to not invalidate the cached layers above
+ARG DB=sqlite,mysql,postgresql
# Builds your dependencies and removes the
# dummy project, except the target folder
@@ -136,6 +132,8 @@ RUN source /env-cargo && \
# To avoid copying unneeded files, use .dockerignore
COPY . .
+ARG VW_VERSION
+
# Builds again, this time it will be the actual source files being build
RUN source /env-cargo && \
# Make sure that we actually build the project by updating the src/main.rs timestamp
@@ -193,8 +191,7 @@ EXPOSE 3012
# and the binary from the "build" stage to the current stage
WORKDIR /
-COPY docker/healthcheck.sh /healthcheck.sh
-COPY docker/start.sh /start.sh
+COPY docker/healthcheck.sh docker/start.sh /
COPY --from=vault /web-vault ./web-vault
COPY --from=build /app/target/final/vaultwarden .