Skip to content

Commit

Permalink
rename built package
Browse files Browse the repository at this point in the history
  • Loading branch information
greizgh committed May 4, 2021
1 parent 16b9d95 commit ffb4d2a
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ git/
dist/
debian/config.env
debian/control
debian/bitwarden_rs.service
debian/vaultwarden.service
Dockerfile
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Then:
```
git clone https://github.com/greizgh/bitwarden_rs-debian.git
cd bitwarden_rs-debian
./build.sh -r <version> # target bitwarden_rs version, example 1.19.0
./build.sh -r <version> # target vaultwarden version, example 1.19.0
```

The `build.sh` script will build bitwarden_rs for the same Debian version which targets vaultwarden.
The `build.sh` script will build vaultwarden for the same Debian version which targets vaultwarden.
That means, to build vaultwarden v1.19.0, make sure to checkout tag `v1.19.0` of this project.

To compile for a different Debian version, specify the release name (e.g. Stretch, Buster) using the `-o` option. You can compile for arm32v7 or amd64 architecture using the `-a` option, only the Buster (default) release of debian is supported by arm32v7.
Expand All @@ -33,7 +33,7 @@ To compile for a different Debian version, specify the release name (e.g. Stretc

The packaged systemd unit is **disabled**, you need to configure vaultwarden through its
[EnvFile](https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines):
`/etc/bitwarden_rs/config.env`
`/etc/vaultwarden/config.env`

You will also probably want to setup a reverse proxy.

Expand Down
16 changes: 8 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if [ -z "$ARCH_DIR" ]; then ARCH_DIR="amd64"; fi
ARCH=$ARCH_DIR
if [[ "$ARCH" =~ ^arm ]]; then ARCH="armhf"; fi

# Clone bitwarden_rs
# Clone vaultwarden
if [ ! -d "$SRC" ]; then
git clone https://github.com/dani-garcia/vaultwarden.git "$SRC"
fi
Expand All @@ -45,8 +45,8 @@ cd - || exit
# Prepare EnvFile
CONFIG="$DIR/debian/config.env"
cp "$SRC/.env.template" "$CONFIG"
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#\# DATA_FOLDER=data#DATA_FOLDER=/var/lib/vaultwarden#" "$CONFIG"
sed -i "s#\# WEB_VAULT_FOLDER=web-vault/#WEB_VAULT_FOLDER=/usr/share/vaultwarden/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"

mkdir -p "$DST"
Expand All @@ -63,19 +63,19 @@ sed -i "s/Version:.*/Version: $REF-1/" "$CONTROL"
sed -i "s/Architecture:.*/Architecture: $ARCH/" "$CONTROL"

# Prepare Systemd-unit
SYSTEMD_UNIT="$DIR/debian/bitwarden_rs.service"
SYSTEMD_UNIT="$DIR/debian/vaultwarden.service"
cp "$DIR/service.dist" "$SYSTEMD_UNIT"
if [ "$DB_TYPE" = "mysql" ]; then
sed -i "s/After=network.target/After=network.target mysqld.service\nRequires=mysqld.service/g" "$SYSTEMD_UNIT"
elif [ "$DB_TYPE" = "postgresql" ]; then
sed -i "s/After=network.target/After=network.target postgresql.service\nRequires=postgresql.service/g" "$SYSTEMD_UNIT"
fi

echo "[INFO] docker build -t bitwarden-deb "$DIR" --build-arg DB=$DB_TYPE"
echo "[INFO] docker build -t vaultwarden-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"
docker build -t vaultwarden-deb "$SRC" --build-arg DB=$DB_TYPE --target dpkg -f "$DIR/Dockerfile"
pushd "$SRC"; git clean -fd; popd

CID=$(docker run -d bitwarden-deb)
docker cp "$CID":/bitwarden_package/vaultwarden.deb "$DST/vaultwarden-${OS_VERSION_NAME}-${REF}-${DB_TYPE}-${ARCH_DIR}.deb"
CID=$(docker run -d vaultwarden-deb)
docker cp "$CID":/vaultwarden_package/vaultwarden.deb "$DST/vaultwarden-${OS_VERSION_NAME}-${REF}-${DB_TYPE}-${ARCH_DIR}.deb"
docker rm "$CID"
2 changes: 1 addition & 1 deletion control.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Package: bitwarden-rs
Package: vaultwarden
Architecture: -
Maintainer: Greizgh <[email protected]>
Priority: optional
Expand Down
4 changes: 2 additions & 2 deletions debian/conffiles
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/etc/bitwarden_rs/Rocket.toml
/etc/bitwarden_rs/config.env
/etc/vaultwarden/Rocket.toml
/etc/vaultwarden/config.env
8 changes: 4 additions & 4 deletions debian/postinst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
DIR_MODE=0700 adduser --system --home /var/lib/bitwarden_rs bitwarden
chmod 700 /var/lib/bitwarden_rs
chmod 600 /etc/bitwarden_rs/config.env
chmod 600 /etc/bitwarden_rs/Rocket.toml
DIR_MODE=0700 adduser --system --home /var/lib/vaultwarden vaultwarden
chmod 700 /var/lib/vaultwarden
chmod 600 /etc/vaultwarden/config.env
chmod 600 /etc/vaultwarden/Rocket.toml
28 changes: 14 additions & 14 deletions patch/amd64/Dockerfile.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
+
+####################### 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
+RUN mkdir -p /vaultwarden_package/DEBIAN
+RUN mkdir -p /vaultwarden_package/usr/local/bin
+RUN mkdir -p /vaultwarden_package/usr/lib/systemd/system
+RUN mkdir -p /vaultwarden_package/etc/vaultwarden
+RUN mkdir -p /vaultwarden_package/usr/share/vaultwarden
+
+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/release/vaultwarden /bitwarden_package/usr/local/bin
+WORKDIR /vaultwarden_package
+COPY debian/control /vaultwarden_package/DEBIAN/control
+COPY debian/postinst /vaultwarden_package/DEBIAN/postinst
+COPY debian/conffiles /vaultwarden_package/DEBIAN/conffiles
+COPY Rocket.toml /vaultwarden_package/etc/vaultwarden
+COPY debian/config.env /vaultwarden_package/etc/vaultwarden
+COPY debian/vaultwarden.service /vaultwarden_package/usr/lib/systemd/system
+COPY --from=vault /web-vault /vaultwarden_package/usr/share/vaultwarden/web-vault
+COPY --from=build app/target/release/vaultwarden /vaultwarden_package/usr/local/bin
+
+RUN dpkg-deb --build . vaultwarden.deb
28 changes: 14 additions & 14 deletions patch/armv7/Dockerfile.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
+
+####################### 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
+RUN mkdir -p /vaultwarden_package/DEBIAN
+RUN mkdir -p /vaultwarden_package/usr/local/bin
+RUN mkdir -p /vaultwarden_package/usr/lib/systemd/system
+RUN mkdir -p /vaultwarden_package/etc/vaultwarden
+RUN mkdir -p /vaultwarden_package/usr/share/vaultwarden
+
+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/vaultwarden /bitwarden_package/usr/local/bin
+WORKDIR /vaultwarden_package
+COPY debian/control /vaultwarden_package/DEBIAN/control
+COPY debian/postinst /vaultwarden_package/DEBIAN/postinst
+COPY debian/conffiles /vaultwarden_package/DEBIAN/conffiles
+COPY Rocket.toml /vaultwarden_package/etc/vaultwarden
+COPY debian/config.env /vaultwarden_package/etc/vaultwarden
+COPY debian/vaultwarden.service /vaultwarden_package/usr/lib/systemd/system
+COPY --from=vault /web-vault /vaultwarden_package/usr/share/vaultwarden/web-vault
+COPY --from=build app/target/armv7-unknown-linux-gnueabihf/release/vaultwarden /vaultwarden_package/usr/local/bin
+
+RUN dpkg-deb --build . vaultwarden.deb
10 changes: 5 additions & 5 deletions service.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ After=network.target

[Service]
Type=simple
User=bitwarden
ExecStart=/usr/local/bin/bitwarden_rs
User=vaultwarden
ExecStart=/usr/local/bin/vaultwarden
PrivateTmp=true
PrivateDevices=true
ProtectHome=true
ProtectSystem=strict
WorkingDirectory=/etc/bitwarden_rs
ReadWriteDirectories=/var/lib/bitwarden_rs
EnvironmentFile=/etc/bitwarden_rs/config.env
WorkingDirectory=/etc/vaultwarden
ReadWriteDirectories=/var/lib/vaultwarden
EnvironmentFile=/etc/vaultwarden/config.env

[Install]
WantedBy=multi-user.target

0 comments on commit ffb4d2a

Please sign in to comment.