Merge pull request #1 from greizgh/master

merge upstream
This commit is contained in:
Nico
2020-11-10 09:39:10 +01:00
committed by GitHub
2 changed files with 42 additions and 21 deletions
+39 -18
View File
@@ -1,6 +1,13 @@
--- git/docker/amd64/sqlite/Dockerfile 2020-07-22 18:23:44.754032681 +0200 --- ./git/docker/amd64/Dockerfile 2020-10-11 13:07:49.749465588 +0200
+++ Dockerfile 2020-07-22 18:29:57.149135164 +0200 +++ ./Dockerfile 2020-10-11 14:00:43.341362012 +0200
@@ -36,9 +36,9 @@ @@ -34,72 +34,68 @@
--no-install-recommends \
libmariadb-dev \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Creates a dummy project used to grab dependencies
RUN USER=root cargo new --bin /app
WORKDIR /app WORKDIR /app
# Copies over *only* your manifests and build files # Copies over *only* your manifests and build files
@@ -11,9 +18,12 @@
+COPY git/rust-toolchain ./rust-toolchain +COPY git/rust-toolchain ./rust-toolchain
+COPY git/build.rs ./build.rs +COPY git/build.rs ./build.rs
# Builds your dependencies and removes the # Builds your dependencies and removes the
# dummy project, except the target folder # dummy project, except the target folder
@@ -48,7 +48,7 @@ # This folder contains the compiled dependencies
RUN cargo build --features ${DB} --release
RUN find . -not -path "./target*" -delete
# Copies the complete project # Copies the complete project
# To avoid copying unneeded files, use .dockerignore # To avoid copying unneeded files, use .dockerignore
@@ -22,7 +32,13 @@
# Make sure that we actually build the project # Make sure that we actually build the project
RUN touch src/main.rs RUN touch src/main.rs
@@ -62,10 +62,6 @@
# Builds again, this time it'll just be
# your actual source files being built
RUN cargo build --features ${DB} --release
######################## RUNTIME IMAGE ########################
# Create a new stage with a minimal image
# because we already have a binary built # because we already have a binary built
FROM debian:buster-slim FROM debian:buster-slim
@@ -33,25 +49,21 @@
# Install needed libraries # Install needed libraries
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
--no-install-recommends \ --no-install-recommends \
@@ -75,22 +71,25 @@ openssl \
ca-certificates \
curl \
sqlite3 \ sqlite3 \
libmariadb-dev-compat \
libpq5 \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
-RUN mkdir /data -RUN mkdir /data
-VOLUME /data -VOLUME /data
-EXPOSE 80 -EXPOSE 80
-EXPOSE 3012 -EXPOSE 3012
+# Create package directory -
+RUN mkdir -p /bitwarden_package/DEBIAN -# Copies the files from the context (Rocket.toml file and web-vault)
+RUN mkdir -p /bitwarden_package/usr/local/bin -# and the binary from the "build" stage to the current stage
+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
# 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 Rocket.toml .
-COPY --from=vault /web-vault ./web-vault -COPY --from=vault /web-vault ./web-vault
-COPY --from=build app/target/release/bitwarden_rs . -COPY --from=build app/target/release/bitwarden_rs .
@@ -64,6 +76,15 @@
-# Configures the startup! -# Configures the startup!
-WORKDIR / -WORKDIR /
-CMD ["/start.sh"] -CMD ["/start.sh"]
+# Create package directory
+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/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
@@ -72,6 +93,6 @@
+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 +# Create the package
+RUN dpkg-deb --build . bitwarden-rs.deb +RUN dpkg-deb --build . bitwarden-rs.deb
+3 -3
View File
@@ -44,11 +44,10 @@ sed -i "s#\# DATA_FOLDER=data#DATA_FOLDER=/var/lib/bitwarden_rs#" "$CONFIG"
sed -i "s#\# WEB_VAULT_FOLDER=web-vault/#WEB_VAULT_FOLDER=/usr/share/bitwarden_rs/web-vault/#" "$CONFIG" sed -i "s#\# WEB_VAULT_FOLDER=web-vault/#WEB_VAULT_FOLDER=/usr/share/bitwarden_rs/web-vault/#" "$CONFIG"
sed -i "s/Uncomment any of the following lines to change the defaults/Uncomment any of the following lines to change the defaults\n\n## Warning\n## The default systemd-unit does not allow any custom directories.\n## Be sure to check if the service has appropriate permissions before you set custom paths./g" "$CONFIG" sed -i "s/Uncomment any of the following lines to change the defaults/Uncomment any of the following lines to change the defaults\n\n## Warning\n## The default systemd-unit does not allow any custom directories.\n## Be sure to check if the service has appropriate permissions before you set custom paths./g" "$CONFIG"
mkdir -p "$DST" mkdir -p "$DST"
# Prepare Dockerfile # Prepare Dockerfile
patch -i "$DIR/Dockerfile.patch" "$SRC/docker/amd64/$DB_TYPE/Dockerfile" -o "$DIR/Dockerfile" || exit patch -i "$DIR/Dockerfile.patch" "$SRC/docker/amd64/Dockerfile" --verbose -o "$DIR/Dockerfile" || exit
sed -E "s/(FROM[[:space:]]*rust:)[^[:space:]]+(.+)/\1${OS_VERSION_NAME}\2/g" -i "$DIR/Dockerfile" sed -E "s/(FROM[[:space:]]*rust:)[^[:space:]]+(.+)/\1${OS_VERSION_NAME}\2/g" -i "$DIR/Dockerfile"
sed -E "s/(FROM[[:space:]]*debian:)[^-]+(-.+)/\1${OS_VERSION_NAME}\2/g" -i "$DIR/Dockerfile" sed -E "s/(FROM[[:space:]]*debian:)[^-]+(-.+)/\1${OS_VERSION_NAME}\2/g" -i "$DIR/Dockerfile"
@@ -65,7 +64,8 @@ elif [ "$DB_TYPE" = "postgresql" ]; then
sed -i "s/After=network.target/After=network.target postgresql.service\nRequires=postgresql.service/g" "$SYSTEMD_UNIT" sed -i "s/After=network.target/After=network.target postgresql.service\nRequires=postgresql.service/g" "$SYSTEMD_UNIT"
fi fi
docker build -t bitwarden-deb "$DIR" echo "[INFO] docker build -t bitwarden-deb "$DIR" --build-arg DB=$DB_TYPE"
docker build -t bitwarden-deb "$DIR" --build-arg DB=$DB_TYPE
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}.deb" docker cp "$CID":/bitwarden_package/bitwarden-rs.deb "$DST/bitwarden_rs-${OS_VERSION_NAME}-${REF}-${DB_TYPE}.deb"