2020-03-01 02:34:55 +03:00
|
|
|
# Compile the web vault using docker
|
|
|
|
# Usage:
|
2022-07-15 17:40:21 +03:00
|
|
|
# Quick and easy:
|
|
|
|
# `make docker-extract`
|
|
|
|
# or, if you just want to build
|
|
|
|
# `make docker`
|
|
|
|
#
|
2020-03-01 02:34:55 +03:00
|
|
|
# docker build -t web_vault_build .
|
|
|
|
# image_id=$(docker create web_vault_build)
|
|
|
|
# docker cp $image_id:/bw_web_vault.tar.gz .
|
|
|
|
# docker rm $image_id
|
|
|
|
#
|
|
|
|
# Note: you can use --build-arg to specify the version to build:
|
|
|
|
# docker build -t web_vault_build --build-arg VAULT_VERSION=master .
|
|
|
|
|
2020-03-26 00:00:56 +03:00
|
|
|
# image_id=$(docker create bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c)
|
|
|
|
# docker cp $image_id:/bw_web_vault.tar.gz .
|
|
|
|
# docker rm $image_id
|
|
|
|
|
2022-04-23 18:04:11 +03:00
|
|
|
FROM node:16-bullseye as build
|
2022-06-02 21:26:42 +03:00
|
|
|
RUN node --version && npm --version
|
2020-03-01 02:34:55 +03:00
|
|
|
|
|
|
|
# Prepare the folder to enable non-root, otherwise npm will refuse to run the postinstall
|
|
|
|
RUN mkdir /vault
|
|
|
|
RUN chown node:node /vault
|
|
|
|
USER node
|
|
|
|
|
|
|
|
# Can be a tag, release, but prefer a commit hash because it's not changeable
|
2022-07-15 17:40:21 +03:00
|
|
|
# https://github.com/bitwarden/clients/commit/${VAULT_VERSION}
|
2020-03-14 16:05:25 +03:00
|
|
|
#
|
2022-09-07 21:24:38 +03:00
|
|
|
# Using https://github.com/bitwarden/clients/releases/tag/web-v2022.9.0
|
|
|
|
ARG VAULT_VERSION=b30fc13fb526029a81304a26c31cb0acd6219241
|
2020-03-01 02:34:55 +03:00
|
|
|
|
2022-06-29 16:49:38 +03:00
|
|
|
RUN git clone https://github.com/bitwarden/clients.git /vault
|
2020-03-01 02:34:55 +03:00
|
|
|
WORKDIR /vault
|
|
|
|
|
2022-06-29 16:49:38 +03:00
|
|
|
RUN git -c advice.detachedHead=false checkout "${VAULT_VERSION}"
|
2020-03-01 02:34:55 +03:00
|
|
|
|
|
|
|
COPY --chown=node:node patches /patches
|
2022-06-02 21:26:42 +03:00
|
|
|
COPY --chown=node:node scripts/apply_patches.sh /apply_patches.sh
|
2020-03-01 02:34:55 +03:00
|
|
|
|
|
|
|
RUN bash /apply_patches.sh
|
|
|
|
|
|
|
|
# Build
|
2022-02-23 16:20:20 +03:00
|
|
|
RUN npm ci
|
2022-03-19 13:29:49 +03:00
|
|
|
RUN npm audit fix || true
|
2022-06-29 16:49:38 +03:00
|
|
|
|
|
|
|
# Switch to the web apps folder
|
|
|
|
WORKDIR /vault/apps/web
|
|
|
|
|
2021-10-27 23:31:31 +03:00
|
|
|
RUN npm run dist:oss:selfhost
|
2020-03-01 02:34:55 +03:00
|
|
|
|
2021-04-04 16:58:06 +03:00
|
|
|
RUN printf '{"version":"%s"}' \
|
|
|
|
$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/dani-garcia/bw_web_builds.git 'v*' | tail -n1 | sed -E 's#.*?refs/tags/v##') \
|
2022-02-23 16:20:20 +03:00
|
|
|
> build/vw-version.json
|
2021-04-04 16:58:06 +03:00
|
|
|
|
2020-03-01 02:34:55 +03:00
|
|
|
# Delete debugging map files, optional
|
|
|
|
# RUN find build -name "*.map" -delete
|
|
|
|
|
|
|
|
# Prepare the final archives
|
|
|
|
RUN mv build web-vault
|
|
|
|
RUN tar -czvf "bw_web_vault.tar.gz" web-vault --owner=0 --group=0
|
|
|
|
|
2020-03-01 03:21:51 +03:00
|
|
|
# We copy the final result as a separate empty image so there's no need to download all the intermediate steps
|
|
|
|
# The result is included both uncompressed and as a tar.gz, to be able to use it in the docker images and the github releases directly
|
2020-03-01 02:34:55 +03:00
|
|
|
FROM scratch
|
2021-07-25 18:53:14 +03:00
|
|
|
# hadolint ignore=DL3010
|
2022-06-29 16:49:38 +03:00
|
|
|
COPY --from=build /vault/apps/web/bw_web_vault.tar.gz /bw_web_vault.tar.gz
|
|
|
|
COPY --from=build /vault/apps/web/web-vault /web-vault
|
2020-03-01 03:21:51 +03:00
|
|
|
# Added so docker create works, can't actually run a scratch image
|
|
|
|
CMD [""]
|