From 0244cc9201e994cf36fc3ca29c2c731892101de8 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 12:28:12 -0500
Subject: [PATCH 001/184] Switch Dockerfile to multi-arch build
---
.github/workflows/build.yml | 117 ++++++++++++++++--------------------
src/Admin/Dockerfile | 52 ++++++++++++++--
2 files changed, 100 insertions(+), 69 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e5f1d1c57d..fa0af7bbe3 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -94,6 +94,7 @@ jobs:
fail-on-error: true
build-artifacts:
+ if: false
name: Build artifacts
runs-on: ubuntu-22.04
needs:
@@ -194,59 +195,48 @@ jobs:
build-docker:
name: Build Docker images
runs-on: ubuntu-22.04
- needs: build-artifacts
+ needs:
+ - lint
+ - testing
strategy:
fail-fast: false
matrix:
include:
- project_name: Admin
base_path: ./src
- dotnet: true
- - project_name: Api
- base_path: ./src
- dotnet: true
- - project_name: Attachments
- base_path: ./util
- - project_name: Billing
- base_path: ./src
- dotnet: true
- - project_name: Events
- base_path: ./src
- dotnet: true
- - project_name: EventsProcessor
- base_path: ./src
- dotnet: true
- - project_name: Icons
- base_path: ./src
- dotnet: true
- - project_name: Identity
- base_path: ./src
- dotnet: true
- - project_name: MsSql
- base_path: ./util
- - project_name: MsSqlMigratorUtility
- base_path: ./util
- dotnet: true
- - project_name: Nginx
- base_path: ./util
- - project_name: Notifications
- base_path: ./src
- dotnet: true
- - project_name: Scim
- base_path: ./bitwarden_license/src
- dotnet: true
- - project_name: Server
- base_path: ./util
- dotnet: true
- - project_name: Setup
- base_path: ./util
- dotnet: true
- - project_name: Sso
- base_path: ./bitwarden_license/src
- dotnet: true
+ # - project_name: Api
+ # base_path: ./src
+ # - project_name: Attachments
+ # base_path: ./util
+ # - project_name: Billing
+ # base_path: ./src
+ # - project_name: Events
+ # base_path: ./src
+ # - project_name: EventsProcessor
+ # base_path: ./src
+ # - project_name: Icons
+ # base_path: ./src
+ # - project_name: Identity
+ # base_path: ./src
+ # - project_name: MsSql
+ # base_path: ./util
+ # - project_name: MsSqlMigratorUtility
+ # base_path: ./util
+ # - project_name: Nginx
+ # base_path: ./util
+ # - project_name: Notifications
+ # base_path: ./src
+ # - project_name: Scim
+ # base_path: ./bitwarden_license/src
+ # - project_name: Server
+ # base_path: ./util
+ # - project_name: Setup
+ # base_path: ./util
+ # - project_name: Sso
+ # base_path: ./bitwarden_license/src
steps:
- name: Checkout repo
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Check Branch to Publish
env:
@@ -261,6 +251,13 @@ jobs:
echo "is_publish_branch=false" >> $GITHUB_ENV
fi
+ ########## Set up Docker ##########
+ - name: Set up QEMU emulators
+ uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
+
########## ACRs ##########
- name: Login to Azure - PROD Subscription
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
@@ -268,7 +265,7 @@ jobs:
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
- name: Login to PROD ACR
- run: az acr login -n bitwardenprod
+ run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
- name: Login to Azure - CI Subscription
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
@@ -307,37 +304,30 @@ jobs:
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
run: echo "name=${_AZ_REGISTRY}/${PROJECT_NAME}:${IMAGE_TAG}" >> $GITHUB_OUTPUT
- - name: Get build artifact
- if: ${{ matrix.dotnet }}
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
- with:
- name: ${{ matrix.project_name }}.zip
-
- - name: Setup build artifact
- if: ${{ matrix.dotnet }}
- run: |
- mkdir -p ${{ matrix.base_path}}/${{ matrix.project_name }}/obj/build-output/publish
- unzip ${{ matrix.project_name }}.zip \
- -d ${{ matrix.base_path }}/${{ matrix.project_name }}/obj/build-output/publish
-
- name: Build Docker image
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3.3.1
with:
context: ${{ matrix.base_path }}/${{ matrix.project_name }}
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
- platforms: linux/amd64
+ platforms: |
+ linux/amd64,
+ linux/arm/v7,
+ linux/arm64/v8
push: true
tags: ${{ steps.image-name.outputs.name }}
secrets: |
"GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
+ - name: Log out of Docker
+ run: docker logout
+
upload:
name: Upload
runs-on: ubuntu-22.04
needs: build-docker
steps:
- name: Checkout repo
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up dotnet
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
@@ -348,7 +338,7 @@ jobs:
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
- name: Login to PROD ACR
- run: az acr login -n $_AZ_REGISTRY --only-show-errors
+ run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
- name: Restore
run: dotnet tool restore
@@ -518,8 +508,7 @@ jobs:
self-host-build:
name: Trigger self-host build
runs-on: ubuntu-22.04
- needs:
- - build-docker
+ needs: build-docker
steps:
- name: Login to Azure - CI Subscription
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 1c2264bf20..11303d7a63 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -1,17 +1,59 @@
-FROM mcr.microsoft.com/dotnet/aspnet:6.0
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:6.0 AS dotnet-build
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+ENV NODE_VERSION=16
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Add packages
+RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
+RUN npm install -g gulp
+
+WORKDIR /source
+COPY *.csproj .
+COPY ../../Directory.Build.props .
+
+# Restore Admin project dependencies and tools
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+COPY . .
+#COPY ../../.git/. ./.git/
+
+# Build Admin app
+RUN npm install
+RUN gulp --gulpfile "gulpfile.js" build
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Admin --no-restore --no-self-contained -r $RID
+
+###############################################
+# App stage #
+###############################################
+FROM mcr.microsoft.com/dotnet/aspnet:6.0
+ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
+ENV ASPNETCORE_ENVIRONMENT=Production
+ENV ASPNETCORE_URLS http://+:5000
+EXPOSE 5000
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
- gosu \
curl \
+ gosu \
&& rm -rf /var/lib/apt/lists/*
-ENV ASPNETCORE_URLS http://+:5000
+# Copy all apps from dotnet-build stage
WORKDIR /app
-EXPOSE 5000
-COPY obj/build-output/publish .
+COPY --from=dotnet-build /app ./
+
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
From e78369e70d4e4e711087e1d1f995f570f5aba035 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 12:35:55 -0500
Subject: [PATCH 002/184] Change logic for testing
---
.github/workflows/build.yml | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index fa0af7bbe3..e0b212347a 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -43,6 +43,7 @@ jobs:
run: dotnet format --verify-no-changes
testing:
+ if: false
name: Testing
runs-on: ubuntu-22.04
env:
@@ -195,9 +196,9 @@ jobs:
build-docker:
name: Build Docker images
runs-on: ubuntu-22.04
- needs:
- - lint
- - testing
+ # needs:
+ # - lint
+ # - testing
strategy:
fail-fast: false
matrix:
From 0a016b48e382a6cb57ee3f672c7bce08d5ba8c89 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 12:39:00 -0500
Subject: [PATCH 003/184] Change Docker context
---
.github/workflows/build.yml | 2 +-
src/Admin/Dockerfile | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e0b212347a..7755566e27 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -308,7 +308,7 @@ jobs:
- name: Build Docker image
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3.3.1
with:
- context: ${{ matrix.base_path }}/${{ matrix.project_name }}
+ context: .
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
platforms: |
linux/amd64,
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 11303d7a63..25b7fd104e 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -20,13 +20,13 @@ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | b
RUN npm install -g gulp
WORKDIR /source
-COPY *.csproj .
-COPY ../../Directory.Build.props .
+COPY src/Admin/*.csproj .
+COPY Directory.Build.props .
# Restore Admin project dependencies and tools
RUN . /tmp/rid.txt && dotnet restore -r $RID
-COPY . .
+COPY src/Admin/. .
#COPY ../../.git/. ./.git/
# Build Admin app
From f7507b306f80d629b06558e451edaa13c900ac37 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 12:40:55 -0500
Subject: [PATCH 004/184] Fix copy source
---
src/Admin/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 25b7fd104e..4cfbf03448 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -54,7 +54,7 @@ RUN apt-get update \
WORKDIR /app
COPY --from=dotnet-build /app ./
-COPY entrypoint.sh /
+COPY src/Admin/entrypoint.sh /
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000 || exit 1
From cbb339c2f33ec934b1b1c55e01fdebbdd0c3bddc Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 12:43:21 -0500
Subject: [PATCH 005/184] Add curl to Dockerfile
---
.github/workflows/build.yml | 2 ++
src/Admin/Dockerfile | 5 +++++
2 files changed, 7 insertions(+)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7755566e27..503c5045c5 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -15,6 +15,7 @@ env:
jobs:
cloc:
+ if: false
name: CLOC
runs-on: ubuntu-22.04
steps:
@@ -30,6 +31,7 @@ jobs:
run: cloc --include-lang C#,SQL,Razor,"Bourne Shell",PowerShell,HTML,CSS,Sass,JavaScript,TypeScript --vcs git
lint:
+ if: false
name: Lint
runs-on: ubuntu-22.04
steps:
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 4cfbf03448..fd1f15c971 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -15,6 +15,11 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
fi \
&& echo "RID=$RID" > /tmp/rid.txt
+# Add packages
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ curl \
+ && rm -rf /var/lib/apt/lists/*
+
# Add packages
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
RUN npm install -g gulp
From b415414e5a2a4dfcadc433f64be1b19d198dd542 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 12:47:48 -0500
Subject: [PATCH 006/184] NVM not picked up by bash
---
src/Admin/Dockerfile | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index fd1f15c971..2efb3d4742 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -22,6 +22,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# Add packages
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
+RUN . ~/.bash_profile
RUN npm install -g gulp
WORKDIR /source
From 9bd152dc5df3473ba8a77661f5e0d4979bd369e9 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 12:51:16 -0500
Subject: [PATCH 007/184] Try .bash_rc
---
src/Admin/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 2efb3d4742..5b9b66defe 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -22,7 +22,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# Add packages
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
-RUN . ~/.bash_profile
+RUN . ~/.bash_rc
RUN npm install -g gulp
WORKDIR /source
From 92179aca6bec24d71a6b5eb40a5a7a48955dda1a Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 12:56:19 -0500
Subject: [PATCH 008/184] Fix nvm
---
src/Admin/Dockerfile | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 5b9b66defe..d333589b52 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -3,6 +3,7 @@ FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:6.0 AS dotnet-bui
# Docker buildx supplies the value for this arg
ARG TARGETPLATFORM
ENV NODE_VERSION=16
+ENV NVM_DIR /usr/local/nvm
# Determine proper runtime value for .NET
# We put the value in a file to be read by later layers.
@@ -21,8 +22,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# Add packages
-RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
-RUN . ~/.bash_rc
+RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
+ && . $NVM_DIR/nvm.sh \
+ && nvm install $NODE_VERSION \
+ && nvm alias default $NODE_VERSION \
+ && nvm use default
RUN npm install -g gulp
WORKDIR /source
From 9582503dbc38e5e4cfc0674237625ea5b4c6aaee Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 12:59:39 -0500
Subject: [PATCH 009/184] Fix nvm
---
src/Admin/Dockerfile | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index d333589b52..ed90325e1a 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -22,6 +22,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# Add packages
+RUN mkdir -p $NVM_DIR
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
From 2d66c3bbc63619f85d7eb5dca47a392dd6bd8e9e Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 13:03:48 -0500
Subject: [PATCH 010/184] Fix nvm
---
src/Admin/Dockerfile | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index ed90325e1a..fcd47f2326 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -2,7 +2,7 @@ FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:6.0 AS dotnet-bui
# Docker buildx supplies the value for this arg
ARG TARGETPLATFORM
-ENV NODE_VERSION=16
+ENV NODE_VERSION=16.20.2
ENV NVM_DIR /usr/local/nvm
# Determine proper runtime value for .NET
@@ -28,6 +28,9 @@ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | b
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
+ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
+ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
+
RUN npm install -g gulp
WORKDIR /source
From e55a205e29c14379751e4e12caa3aff3125a068f Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 13:08:21 -0500
Subject: [PATCH 011/184] Change build image to SDK
---
src/Admin/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index fcd47f2326..6e994d8702 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -1,4 +1,4 @@
-FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:6.0 AS dotnet-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS dotnet-build
# Docker buildx supplies the value for this arg
ARG TARGETPLATFORM
From e5765289012147c3a7cf875d21c41ae7d31e98df Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 13:32:03 -0500
Subject: [PATCH 012/184] Change logic for building
---
.github/workflows/build.yml | 38 ++++++++-
build.Dockerfile | 151 ++++++++++++++++++++++++++++++++++++
src/Admin/Dockerfile | 63 +++------------
3 files changed, 196 insertions(+), 56 deletions(-)
create mode 100644 build.Dockerfile
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 503c5045c5..4343afd31d 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -195,12 +195,41 @@ jobs:
path: ${{ matrix.base_path }}/${{ matrix.project_name }}/${{ matrix.project_name }}.zip
if-no-files-found: error
- build-docker:
- name: Build Docker images
+ build:
+ name: Build artifacts
runs-on: ubuntu-22.04
# needs:
# - lint
# - testing
+ steps:
+ - name: Checkout repo
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+
+ - name: Set up QEMU emulators
+ uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
+
+ - name: Build Docker image
+ uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3.3.1
+ with:
+ context: .
+ file: build.Dockerfile
+ platforms: |
+ linux/amd64,
+ linux/arm/v7,
+ linux/arm64/v8
+ push: false
+ tags: bitwarden-build
+ # secrets: |
+ # "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
+
+ build-docker:
+ name: Build Docker images
+ runs-on: ubuntu-22.04
+ needs:
+ - build
strategy:
fail-fast: false
matrix:
@@ -254,6 +283,11 @@ jobs:
echo "is_publish_branch=false" >> $GITHUB_ENV
fi
+ - name: Docker Test Step
+ run: |
+ docker image ls
+ exit 1
+
########## Set up Docker ##########
- name: Set up QEMU emulators
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
diff --git a/build.Dockerfile b/build.Dockerfile
new file mode 100644
index 0000000000..a04449c372
--- /dev/null
+++ b/build.Dockerfile
@@ -0,0 +1,151 @@
+###############################################
+# Build stage #
+###############################################
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+ENV NODE_VERSION=16.20.2
+ENV NVM_DIR /usr/local/nvm
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Add packages
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ curl \
+ && rm -rf /var/lib/apt/lists/*
+
+# Set up Node
+RUN mkdir -p $NVM_DIR
+RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
+ && . $NVM_DIR/nvm.sh \
+ && nvm install $NODE_VERSION \
+ && nvm alias default $NODE_VERSION \
+ && nvm use default
+ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
+ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
+
+# Install gulp
+RUN npm install -g gulp
+
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY src/Admin/*.csproj ./src/Admin/
+COPY src/Api/*.csproj ./src/Api/
+COPY src/Events/*.csproj ./src/Events/
+COPY src/Icons/*.csproj ./src/Icons/
+COPY src/Identity/*.csproj ./src/Identity/
+COPY src/Notifications/*.csproj ./src/Notifications/
+COPY bitwarden_license/src/Sso/*.csproj ./bitwarden_license/src/Sso/
+COPY bitwarden_license/src/Scim/*.csproj ./bitwarden_license/src/Scim/
+COPY src/Core/*.csproj ./src/Core/
+COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
+COPY src/SharedWeb/*.csproj ./src/SharedWeb/
+COPY util/Migrator/*.csproj ./util/Migrator/
+COPY util/MySqlMigrations/*.csproj ./util/MySqlMigrations/
+COPY util/PostgresMigrations/*.csproj ./util/PostgresMigrations/
+COPY util/SqliteMigrations/*.csproj ./util/SqliteMigrations/
+COPY bitwarden_license/src/Commercial.Core/*.csproj ./bitwarden_license/src/Commercial.Core/
+COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/*.csproj ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
+COPY Directory.Build.props .
+
+# Restore Admin project dependencies and tools
+WORKDIR /source/src/Admin
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Restore Api project dependencies and tools
+WORKDIR /source/src/Api
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Restore Events project dependencies and tools
+WORKDIR /source/src/Events
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Restore Icons project dependencies and tools
+WORKDIR /source/src/Icons
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Restore Identity project dependencies and tools
+WORKDIR /source/src/Identity
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Restore Notifications project dependencies and tools
+WORKDIR /source/src/Notifications
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Restore Sso project dependencies and tools
+WORKDIR /source/bitwarden_license/src/Sso
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Restore Scim project dependencies and tools
+WORKDIR /source/bitwarden_license/src/Scim
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Copy required project files
+WORKDIR /source
+COPY src/Admin/. ./src/Admin/
+COPY src/Api/. ./src/Api/
+COPY src/Events/. ./src/Events/
+COPY src/Icons/. ./src/Icons/
+COPY src/Identity/. ./src/Identity/
+COPY src/Notifications/. ./src/Notifications/
+COPY bitwarden_license/src/Sso/. ./bitwarden_license/src/Sso/
+COPY bitwarden_license/src/Scim/. ./bitwarden_license/src/Scim/
+COPY src/Core/. ./src/Core/
+COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
+COPY src/SharedWeb/. ./src/SharedWeb/
+COPY util/Migrator/. ./util/Migrator/
+COPY util/MySqlMigrations/. ./util/MySqlMigrations/
+COPY util/PostgresMigrations/. ./util/PostgresMigrations/
+COPY util/SqliteMigrations/. ./util/SqliteMigrations/
+COPY util/EfShared/. ./util/EfShared/
+COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
+COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
+COPY .git/. ./.git/
+
+# Build Admin app
+WORKDIR /source/src/Admin
+RUN npm install
+RUN gulp --gulpfile "gulpfile.js" build
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Admin --no-restore --no-self-contained -r $RID
+
+# Build Api app
+WORKDIR /source/src/Api
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Api --no-restore --no-self-contained -r $RID
+
+# Build Events app
+WORKDIR /source/src/Events
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Events --no-restore --no-self-contained -r $RID
+
+# Build Icons app
+WORKDIR /source/src/Icons
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Icons --no-restore --no-self-contained -r $RID
+
+# Build Identity app
+WORKDIR /source/src/Identity
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Identity --no-restore --no-self-contained -r $RID
+
+# Build Notifications app
+WORKDIR /source/src/Notifications
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Notifications --no-restore --no-self-contained -r $RID
+
+# Build Sso app
+WORKDIR /source/bitwarden_license/src/Sso
+RUN npm install
+RUN gulp --gulpfile "gulpfile.js" build
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Sso --no-restore --no-self-contained -r $RID
+
+# Build Scim app
+WORKDIR /source/bitwarden_license/src/Scim
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Scim --no-restore --no-self-contained -r $RID
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 6e994d8702..f6c1a50439 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -1,57 +1,13 @@
-FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS dotnet-build
-
-# Docker buildx supplies the value for this arg
-ARG TARGETPLATFORM
-ENV NODE_VERSION=16.20.2
-ENV NVM_DIR /usr/local/nvm
-
-# Determine proper runtime value for .NET
-# We put the value in a file to be read by later layers.
-RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
- RID=linux-x64 ; \
- elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
- RID=linux-arm64 ; \
- elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
- RID=linux-arm ; \
- fi \
- && echo "RID=$RID" > /tmp/rid.txt
-
-# Add packages
-RUN apt-get update && apt-get install -y --no-install-recommends \
- curl \
- && rm -rf /var/lib/apt/lists/*
-
-# Add packages
-RUN mkdir -p $NVM_DIR
-RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
- && . $NVM_DIR/nvm.sh \
- && nvm install $NODE_VERSION \
- && nvm alias default $NODE_VERSION \
- && nvm use default
-ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
-ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
-
-RUN npm install -g gulp
-
-WORKDIR /source
-COPY src/Admin/*.csproj .
-COPY Directory.Build.props .
-
-# Restore Admin project dependencies and tools
-RUN . /tmp/rid.txt && dotnet restore -r $RID
-
-COPY src/Admin/. .
-#COPY ../../.git/. ./.git/
-
-# Build Admin app
-RUN npm install
-RUN gulp --gulpfile "gulpfile.js" build
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Admin --no-restore --no-self-contained -r $RID
+###############################################
+# Build stage #
+###############################################
+FROM --platform=$BUILDPLATFORM bitwarden-build AS bitwarden-build
###############################################
# App stage #
###############################################
FROM mcr.microsoft.com/dotnet/aspnet:6.0
+
ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
ENV ASPNETCORE_ENVIRONMENT=Production
@@ -60,15 +16,14 @@ EXPOSE 5000
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
- curl \
gosu \
+ curl \
&& rm -rf /var/lib/apt/lists/*
-# Copy all apps from dotnet-build stage
+# Copy all apps from the build stage
WORKDIR /app
-COPY --from=dotnet-build /app ./
-
-COPY src/Admin/entrypoint.sh /
+COPY --from=bitwarden-build /app/Admin ./
+COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000 || exit 1
From 93a9f4c9d7e1ff8a27f666af16e6b7f503c5bf47 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 13:39:30 -0500
Subject: [PATCH 013/184] Try again for Docker build
---
.github/workflows/build.yml | 9 +++++----
src/Admin/Dockerfile | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 4343afd31d..c90f9279eb 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -212,16 +212,17 @@ jobs:
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
- name: Build Docker image
- uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3.3.1
+ uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
file: build.Dockerfile
+ load: true
platforms: |
linux/amd64,
linux/arm/v7,
linux/arm64/v8
- push: false
- tags: bitwarden-build
+ # push: false
+ tags: bitwarden-build:latest
# secrets: |
# "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
@@ -342,7 +343,7 @@ jobs:
run: echo "name=${_AZ_REGISTRY}/${PROJECT_NAME}:${IMAGE_TAG}" >> $GITHUB_OUTPUT
- name: Build Docker image
- uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3.3.1
+ uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index f6c1a50439..5b35da5870 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -1,7 +1,7 @@
###############################################
# Build stage #
###############################################
-FROM --platform=$BUILDPLATFORM bitwarden-build AS bitwarden-build
+FROM --platform=$BUILDPLATFORM bitwarden-build:latest AS bitwarden-build
###############################################
# App stage #
From 8abe00db65a2e3e0352c25969c773943a761dd97 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 13:46:40 -0500
Subject: [PATCH 014/184] Fix logic
---
.github/workflows/build.yml | 41 ++++++++++++++++++++++++++++---------
1 file changed, 31 insertions(+), 10 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c90f9279eb..0cd8f4f238 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -210,21 +210,41 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
+
+ ########## ACRs ##########
+ - name: Login to Azure - PROD Subscription
+ uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
+ with:
+ creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
+
+ - name: Login to PROD ACR
+ run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
+
+ - name: Login to Azure - CI Subscription
+ uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
+ with:
+ creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
+
+ - name: Retrieve github PAT secrets
+ id: retrieve-secret-pat
+ uses: bitwarden/gh-actions/get-keyvault-secrets@main
+ with:
+ keyvault: "bitwarden-ci"
+ secrets: "github-pat-bitwarden-devops-bot-repo-scope"
- name: Build Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
file: build.Dockerfile
- load: true
platforms: |
linux/amd64,
linux/arm/v7,
linux/arm64/v8
- # push: false
- tags: bitwarden-build:latest
- # secrets: |
- # "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
+ push: false
+ tags: ${{ env._AZ_REGISTRY }}/build:latest
+ secrets: |
+ "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
build-docker:
name: Build Docker images
@@ -284,11 +304,6 @@ jobs:
echo "is_publish_branch=false" >> $GITHUB_ENV
fi
- - name: Docker Test Step
- run: |
- docker image ls
- exit 1
-
########## Set up Docker ##########
- name: Set up QEMU emulators
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
@@ -318,6 +333,12 @@ jobs:
secrets: "github-pat-bitwarden-devops-bot-repo-scope"
########## Generate image tag and build Docker image ##########
+ - name: Docker Test Step
+ run: |
+ docker image pull $_AZ_REGISTRY/build:latest
+ docker image ls
+ exit 1
+
- name: Generate Docker image tag
id: tag
run: |
From cd8c16f4a2758b18b72da86f567ad13d8b48cf22 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 13:53:55 -0500
Subject: [PATCH 015/184] Actually use push flag
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0cd8f4f238..02f5c7cfe6 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -241,7 +241,7 @@ jobs:
linux/amd64,
linux/arm/v7,
linux/arm64/v8
- push: false
+ push: true
tags: ${{ env._AZ_REGISTRY }}/build:latest
secrets: |
"GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
From 8da8388678323bfd816f86bf4013ccd72ea9bbdd Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 14:10:35 -0500
Subject: [PATCH 016/184] Full test
---
.github/workflows/build.yml | 19 ++++++++++++-------
src/Admin/Dockerfile | 3 ++-
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 02f5c7cfe6..eb89786f97 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -232,6 +232,15 @@ jobs:
keyvault: "bitwarden-ci"
secrets: "github-pat-bitwarden-devops-bot-repo-scope"
+ - name: Generate image full name
+ id: image-name
+ run: |
+ IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g") # slash safe branch name
+ if [[ "$IMAGE_TAG" == "master" ]]; then
+ IMAGE_TAG=dev
+ fi
+ echo "name=${_AZ_REGISTRY}/build:${IMAGE_TAG}" >> $GITHUB_OUTPUT
+
- name: Build Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
@@ -242,7 +251,7 @@ jobs:
linux/arm/v7,
linux/arm64/v8
push: true
- tags: ${{ env._AZ_REGISTRY }}/build:latest
+ tags: ${{ steps.image-name.outputs.name }}
secrets: |
"GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
@@ -333,12 +342,6 @@ jobs:
secrets: "github-pat-bitwarden-devops-bot-repo-scope"
########## Generate image tag and build Docker image ##########
- - name: Docker Test Step
- run: |
- docker image pull $_AZ_REGISTRY/build:latest
- docker image ls
- exit 1
-
- name: Generate Docker image tag
id: tag
run: |
@@ -366,6 +369,8 @@ jobs:
- name: Build Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
+ build-args: |
+ BUILD_TAG=${{ steps.tag.outputs.image_tag }}
context: .
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
platforms: |
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 5b35da5870..72be2334f3 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -1,7 +1,8 @@
###############################################
# Build stage #
###############################################
-FROM --platform=$BUILDPLATFORM bitwarden-build:latest AS bitwarden-build
+ARG BUILD_TAG=latest
+FROM --platform=$BUILDPLATFORM bitwarden-build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
From a7fa6c943f9c79ec523360c9539989d326d13edb Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 14:20:48 -0500
Subject: [PATCH 017/184] Fix image name
---
src/Admin/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 72be2334f3..dd12d2bd7b 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM bitwarden-build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
From 2e2ec50f1048d99ea20699df07e6122d31984919 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 15:18:36 -0500
Subject: [PATCH 018/184] Fix build context
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index eb89786f97..dbddba304d 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -371,7 +371,7 @@ jobs:
with:
build-args: |
BUILD_TAG=${{ steps.tag.outputs.image_tag }}
- context: .
+ context: ${{ matrix.base_path }}/${{ matrix.project_name }}
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
platforms: |
linux/amd64,
From 0f2ebde2c5d6b96a621e068d24ab817c304660d4 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 17:07:47 -0500
Subject: [PATCH 019/184] Test all projects
---
.github/workflows/build.yml | 60 +++++++++++++--------------
bitwarden_license/src/Scim/Dockerfile | 18 ++++++--
bitwarden_license/src/Sso/Dockerfile | 18 ++++++--
build.Dockerfile | 40 ++++++++++++++++++
src/Admin/Dockerfile | 2 +-
src/Api/Dockerfile | 18 ++++++--
src/Billing/Dockerfile | 19 +++++++--
src/Events/Dockerfile | 18 ++++++--
src/EventsProcessor/Dockerfile | 20 +++++++--
src/Icons/Dockerfile | 18 ++++++--
src/Identity/Dockerfile | 18 ++++++--
src/Notifications/Dockerfile | 18 ++++++--
util/Attachments/Dockerfile | 20 +++++++--
util/Nginx/Dockerfile | 3 +-
util/Server/Dockerfile | 13 +++++-
util/Setup/Dockerfile | 13 +++++-
16 files changed, 250 insertions(+), 66 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index dbddba304d..146be04514 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -266,36 +266,36 @@ jobs:
include:
- project_name: Admin
base_path: ./src
- # - project_name: Api
- # base_path: ./src
- # - project_name: Attachments
- # base_path: ./util
- # - project_name: Billing
- # base_path: ./src
- # - project_name: Events
- # base_path: ./src
- # - project_name: EventsProcessor
- # base_path: ./src
- # - project_name: Icons
- # base_path: ./src
- # - project_name: Identity
- # base_path: ./src
- # - project_name: MsSql
- # base_path: ./util
- # - project_name: MsSqlMigratorUtility
- # base_path: ./util
- # - project_name: Nginx
- # base_path: ./util
- # - project_name: Notifications
- # base_path: ./src
- # - project_name: Scim
- # base_path: ./bitwarden_license/src
- # - project_name: Server
- # base_path: ./util
- # - project_name: Setup
- # base_path: ./util
- # - project_name: Sso
- # base_path: ./bitwarden_license/src
+ - project_name: Api
+ base_path: ./src
+ - project_name: Attachments
+ base_path: ./util
+ - project_name: Billing
+ base_path: ./src
+ - project_name: Events
+ base_path: ./src
+ - project_name: EventsProcessor
+ base_path: ./src
+ - project_name: Icons
+ base_path: ./src
+ - project_name: Identity
+ base_path: ./src
+ - project_name: MsSql
+ base_path: ./util
+ - project_name: MsSqlMigratorUtility
+ base_path: ./util
+ - project_name: Nginx
+ base_path: ./util
+ - project_name: Notifications
+ base_path: ./src
+ - project_name: Scim
+ base_path: ./bitwarden_license/src
+ - project_name: Server
+ base_path: ./util
+ - project_name: Setup
+ base_path: ./util
+ - project_name: Sso
+ base_path: ./bitwarden_license/src
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
diff --git a/bitwarden_license/src/Scim/Dockerfile b/bitwarden_license/src/Scim/Dockerfile
index f63cb82ce3..e96e000666 100644
--- a/bitwarden_license/src/Scim/Dockerfile
+++ b/bitwarden_license/src/Scim/Dockerfile
@@ -1,6 +1,19 @@
+###############################################
+# Build stage #
+###############################################
+ARG BUILD_TAG=latest
+FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+
+###############################################
+# App stage #
+###############################################
FROM mcr.microsoft.com/dotnet/aspnet:6.0
+ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
+ENV ASPNETCORE_ENVIRONMENT=Production
+ENV ASPNETCORE_URLS http://+:5000
+EXPOSE 5000
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@@ -8,10 +21,9 @@ RUN apt-get update \
curl \
&& rm -rf /var/lib/apt/lists/*
-ENV ASPNETCORE_URLS http://+:5000
+# Copy app from the build stage
WORKDIR /app
-EXPOSE 5000
-COPY obj/build-output/publish .
+COPY --from=bitwarden-build /app/Scim ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/bitwarden_license/src/Sso/Dockerfile b/bitwarden_license/src/Sso/Dockerfile
index f63cb82ce3..e3927e2f12 100644
--- a/bitwarden_license/src/Sso/Dockerfile
+++ b/bitwarden_license/src/Sso/Dockerfile
@@ -1,6 +1,19 @@
+###############################################
+# Build stage #
+###############################################
+ARG BUILD_TAG=latest
+FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+
+###############################################
+# App stage #
+###############################################
FROM mcr.microsoft.com/dotnet/aspnet:6.0
+ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
+ENV ASPNETCORE_ENVIRONMENT=Production
+ENV ASPNETCORE_URLS http://+:5000
+EXPOSE 5000
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@@ -8,10 +21,9 @@ RUN apt-get update \
curl \
&& rm -rf /var/lib/apt/lists/*
-ENV ASPNETCORE_URLS http://+:5000
+# Copy app from the build stage
WORKDIR /app
-EXPOSE 5000
-COPY obj/build-output/publish .
+COPY --from=bitwarden-build /app/Sso ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/build.Dockerfile b/build.Dockerfile
index a04449c372..2984e5a622 100644
--- a/build.Dockerfile
+++ b/build.Dockerfile
@@ -41,7 +41,9 @@ RUN npm install -g gulp
WORKDIR /source
COPY src/Admin/*.csproj ./src/Admin/
COPY src/Api/*.csproj ./src/Api/
+COPY src/Billing/*.csproj ./src/Billing/
COPY src/Events/*.csproj ./src/Events/
+COPY src/EventsProcessor/*.csproj ./src/EventsProcessor/
COPY src/Icons/*.csproj ./src/Icons/
COPY src/Identity/*.csproj ./src/Identity/
COPY src/Notifications/*.csproj ./src/Notifications/
@@ -54,6 +56,8 @@ COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY util/Migrator/*.csproj ./util/Migrator/
COPY util/MySqlMigrations/*.csproj ./util/MySqlMigrations/
COPY util/PostgresMigrations/*.csproj ./util/PostgresMigrations/
+COPY util/Server/*.csproj ./util/Server/
+COPY util/Setup/*.csproj ./util/Setup/
COPY util/SqliteMigrations/*.csproj ./util/SqliteMigrations/
COPY bitwarden_license/src/Commercial.Core/*.csproj ./bitwarden_license/src/Commercial.Core/
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/*.csproj ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
@@ -67,10 +71,18 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
WORKDIR /source/src/Api
RUN . /tmp/rid.txt && dotnet restore -r $RID
+# Restore Billing project dependencies and tools
+WORKDIR /source/src/Billing
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
# Restore Events project dependencies and tools
WORKDIR /source/src/Events
RUN . /tmp/rid.txt && dotnet restore -r $RID
+# Restore Events project dependencies and tools
+WORKDIR /source/src/EventsProcessor
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
# Restore Icons project dependencies and tools
WORKDIR /source/src/Icons
RUN . /tmp/rid.txt && dotnet restore -r $RID
@@ -91,11 +103,21 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
WORKDIR /source/bitwarden_license/src/Scim
RUN . /tmp/rid.txt && dotnet restore -r $RID
+# Restore Server project dependencies and tools
+WORKDIR /source/util/Server
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Restore Setup project dependencies and tools
+WORKDIR /source/util/Setup
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
# Copy required project files
WORKDIR /source
COPY src/Admin/. ./src/Admin/
COPY src/Api/. ./src/Api/
+COPY src/Billing/. ./src/Billing/
COPY src/Events/. ./src/Events/
+COPY src/EventsProcessor/. ./src/EventsProcessor/
COPY src/Icons/. ./src/Icons/
COPY src/Identity/. ./src/Identity/
COPY src/Notifications/. ./src/Notifications/
@@ -108,6 +130,8 @@ COPY src/SharedWeb/. ./src/SharedWeb/
COPY util/Migrator/. ./util/Migrator/
COPY util/MySqlMigrations/. ./util/MySqlMigrations/
COPY util/PostgresMigrations/. ./util/PostgresMigrations/
+COPY util/Server/. ./util/Server/
+COPY util/Setup/. ./util/Setup/
COPY util/SqliteMigrations/. ./util/SqliteMigrations/
COPY util/EfShared/. ./util/EfShared/
COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
@@ -124,10 +148,18 @@ RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Admin --no-restore --no-
WORKDIR /source/src/Api
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Api --no-restore --no-self-contained -r $RID
+# Build Billing app
+WORKDIR /source/src/Billing
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Billing --no-restore --no-self-contained -r $RID
+
# Build Events app
WORKDIR /source/src/Events
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Events --no-restore --no-self-contained -r $RID
+# Build EventsProcessor app
+WORKDIR /source/src/EventsProcessor
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/EventsProcessor --no-restore --no-self-contained -r $RID
+
# Build Icons app
WORKDIR /source/src/Icons
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Icons --no-restore --no-self-contained -r $RID
@@ -149,3 +181,11 @@ RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Sso --no-restore --no-se
# Build Scim app
WORKDIR /source/bitwarden_license/src/Scim
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Scim --no-restore --no-self-contained -r $RID
+
+# Build Server app
+WORKDIR /source/util/Server
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Server --no-restore --no-self-contained -r $RID
+
+# Build Setup app
+WORKDIR /source/util/Setup
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Setup --no-restore --no-self-contained -r $RID
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index dd12d2bd7b..0d3b9578ba 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -21,7 +21,7 @@ RUN apt-get update \
curl \
&& rm -rf /var/lib/apt/lists/*
-# Copy all apps from the build stage
+# Copy app from the build stage
WORKDIR /app
COPY --from=bitwarden-build /app/Admin ./
COPY entrypoint.sh /
diff --git a/src/Api/Dockerfile b/src/Api/Dockerfile
index f63cb82ce3..7e5b68df7e 100644
--- a/src/Api/Dockerfile
+++ b/src/Api/Dockerfile
@@ -1,6 +1,19 @@
+###############################################
+# Build stage #
+###############################################
+ARG BUILD_TAG=latest
+FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+
+###############################################
+# App stage #
+###############################################
FROM mcr.microsoft.com/dotnet/aspnet:6.0
+ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
+ENV ASPNETCORE_ENVIRONMENT=Production
+ENV ASPNETCORE_URLS http://+:5000
+EXPOSE 5000
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@@ -8,10 +21,9 @@ RUN apt-get update \
curl \
&& rm -rf /var/lib/apt/lists/*
-ENV ASPNETCORE_URLS http://+:5000
+# Copy app from the build stage
WORKDIR /app
-EXPOSE 5000
-COPY obj/build-output/publish .
+COPY --from=bitwarden-build /app/Api ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/src/Billing/Dockerfile b/src/Billing/Dockerfile
index cd00c068f7..b651ea59f2 100644
--- a/src/Billing/Dockerfile
+++ b/src/Billing/Dockerfile
@@ -1,6 +1,19 @@
+###############################################
+# Build stage #
+###############################################
+ARG BUILD_TAG=latest
+FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+
+###############################################
+# App stage #
+###############################################
FROM mcr.microsoft.com/dotnet/aspnet:6.0
+ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
+ENV ASPNETCORE_ENVIRONMENT=Production
+ENV ASPNETCORE_URLS http://+:5000
+EXPOSE 5000
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@@ -8,14 +21,12 @@ RUN apt-get update \
curl \
&& rm -rf /var/lib/apt/lists/*
-ENV ASPNETCORE_URLS http://+:5000
+# Copy app from the build stage
WORKDIR /app
-EXPOSE 5000
+COPY --from=bitwarden-build /app/Billing ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
-COPY obj/build-output/publish .
-
HEALTHCHECK CMD curl -f http://localhost:5000/alive || exit 1
ENTRYPOINT ["/entrypoint.sh"]
diff --git a/src/Events/Dockerfile b/src/Events/Dockerfile
index f63cb82ce3..52f4f80390 100644
--- a/src/Events/Dockerfile
+++ b/src/Events/Dockerfile
@@ -1,6 +1,19 @@
+###############################################
+# Build stage #
+###############################################
+ARG BUILD_TAG=latest
+FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+
+###############################################
+# App stage #
+###############################################
FROM mcr.microsoft.com/dotnet/aspnet:6.0
+ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
+ENV ASPNETCORE_ENVIRONMENT=Production
+ENV ASPNETCORE_URLS http://+:5000
+EXPOSE 5000
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@@ -8,10 +21,9 @@ RUN apt-get update \
curl \
&& rm -rf /var/lib/apt/lists/*
-ENV ASPNETCORE_URLS http://+:5000
+# Copy app from the build stage
WORKDIR /app
-EXPOSE 5000
-COPY obj/build-output/publish .
+COPY --from=bitwarden-build /app/Admin ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/src/EventsProcessor/Dockerfile b/src/EventsProcessor/Dockerfile
index 3d505d28ef..15388a9ea9 100644
--- a/src/EventsProcessor/Dockerfile
+++ b/src/EventsProcessor/Dockerfile
@@ -1,6 +1,19 @@
+###############################################
+# Build stage #
+###############################################
+ARG BUILD_TAG=latest
+FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+
+###############################################
+# App stage #
+###############################################
FROM mcr.microsoft.com/dotnet/aspnet:6.0
+ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
+ENV ASPNETCORE_ENVIRONMENT=Production
+ENV ASPNETCORE_URLS http://+:5000
+EXPOSE 5000
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@@ -8,13 +21,12 @@ RUN apt-get update \
curl \
&& rm -rf /var/lib/apt/lists/*
-ENV ASPNETCORE_URLS http://+:5000
+# Copy app from the build stage
WORKDIR /app
-EXPOSE 5000
-COPY obj/build-output/publish .
+COPY --from=bitwarden-build /app/EventsProcessor ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000/alive || exit 1
-CMD ["./../entrypoint.sh"]
+CMD ["/entrypoint.sh"]
diff --git a/src/Icons/Dockerfile b/src/Icons/Dockerfile
index 42514c613e..3cf662b55a 100644
--- a/src/Icons/Dockerfile
+++ b/src/Icons/Dockerfile
@@ -1,6 +1,19 @@
+###############################################
+# Build stage #
+###############################################
+ARG BUILD_TAG=latest
+FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+
+###############################################
+# App stage #
+###############################################
FROM mcr.microsoft.com/dotnet/aspnet:6.0
+ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
+ENV ASPNETCORE_ENVIRONMENT=Production
+ENV ASPNETCORE_URLS http://+:5000
+EXPOSE 5000
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@@ -8,10 +21,9 @@ RUN apt-get update \
curl \
&& rm -rf /var/lib/apt/lists/*
-ENV ASPNETCORE_URLS http://+:5000
+# Copy app from the build stage
WORKDIR /app
-EXPOSE 5000
-COPY obj/build-output/publish .
+COPY --from=bitwarden-build /app/Icons ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/src/Identity/Dockerfile b/src/Identity/Dockerfile
index 6d1adfd484..83c822d2b2 100644
--- a/src/Identity/Dockerfile
+++ b/src/Identity/Dockerfile
@@ -1,6 +1,19 @@
+###############################################
+# Build stage #
+###############################################
+ARG BUILD_TAG=latest
+FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+
+###############################################
+# App stage #
+###############################################
FROM mcr.microsoft.com/dotnet/aspnet:6.0
+ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
+ENV ASPNETCORE_ENVIRONMENT=Production
+ENV ASPNETCORE_URLS http://+:5000
+EXPOSE 5000
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@@ -8,10 +21,9 @@ RUN apt-get update \
curl \
&& rm -rf /var/lib/apt/lists/*
-ENV ASPNETCORE_URLS http://+:5000
+# Copy app from the build stage
WORKDIR /app
-EXPOSE 5000
-COPY obj/build-output/publish .
+COPY --from=bitwarden-build /app/Identity ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/src/Notifications/Dockerfile b/src/Notifications/Dockerfile
index f63cb82ce3..633bc23802 100644
--- a/src/Notifications/Dockerfile
+++ b/src/Notifications/Dockerfile
@@ -1,6 +1,19 @@
+###############################################
+# Build stage #
+###############################################
+ARG BUILD_TAG=latest
+FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+
+###############################################
+# App stage #
+###############################################
FROM mcr.microsoft.com/dotnet/aspnet:6.0
+ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
+ENV ASPNETCORE_ENVIRONMENT=Production
+ENV ASPNETCORE_URLS http://+:5000
+EXPOSE 5000
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@@ -8,10 +21,9 @@ RUN apt-get update \
curl \
&& rm -rf /var/lib/apt/lists/*
-ENV ASPNETCORE_URLS http://+:5000
+# Copy app from the build stage
WORKDIR /app
-EXPOSE 5000
-COPY obj/build-output/publish .
+COPY --from=bitwarden-build /app/Notifications ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/util/Attachments/Dockerfile b/util/Attachments/Dockerfile
index 2d99aa5911..4c620e994b 100644
--- a/util/Attachments/Dockerfile
+++ b/util/Attachments/Dockerfile
@@ -1,6 +1,19 @@
-FROM bitwarden/server:latest
+###############################################
+# Build stage #
+###############################################
+ARG BUILD_TAG=latest
+FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+###############################################
+# App stage #
+###############################################
+FROM mcr.microsoft.com/dotnet/aspnet:6.0
+
+ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
+ENV ASPNETCORE_ENVIRONMENT=Production
+ENV ASPNETCORE_URLS http://+:5000
+EXPOSE 5000
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@@ -8,8 +21,9 @@ RUN apt-get update \
curl \
&& rm -rf /var/lib/apt/lists/*
-ENV ASPNETCORE_URLS http://+:5000
-EXPOSE 5000
+# Copy app from the build stage
+WORKDIR /bitwarden_server
+COPY --from=bitwarden-build /app/Server ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/util/Nginx/Dockerfile b/util/Nginx/Dockerfile
index e868e9b81f..973b616efb 100644
--- a/util/Nginx/Dockerfile
+++ b/util/Nginx/Dockerfile
@@ -1,5 +1,6 @@
-FROM nginx:stable
+FROM --platform=$BUILDPLATFORM nginx:stable
+ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
RUN apt-get update \
diff --git a/util/Server/Dockerfile b/util/Server/Dockerfile
index e26c9b42dc..b052a82ff0 100644
--- a/util/Server/Dockerfile
+++ b/util/Server/Dockerfile
@@ -1,5 +1,16 @@
+###############################################
+# Build stage #
+###############################################
+ARG BUILD_TAG=latest
+FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+
+###############################################
+# App stage #
+###############################################
FROM mcr.microsoft.com/dotnet/aspnet:6.0
LABEL com.bitwarden.product="bitwarden"
-COPY obj/build-output/publish /bitwarden_server
+# Copy app from the build stage
+WORKDIR /bitwarden_server
+COPY --from=bitwarden-build /app/Server ./
\ No newline at end of file
diff --git a/util/Setup/Dockerfile b/util/Setup/Dockerfile
index 6aee1ca315..99182f6d6a 100644
--- a/util/Setup/Dockerfile
+++ b/util/Setup/Dockerfile
@@ -1,5 +1,15 @@
+###############################################
+# Build stage #
+###############################################
+ARG BUILD_TAG=latest
+FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+
+###############################################
+# App stage #
+###############################################
FROM mcr.microsoft.com/dotnet/aspnet:6.0
+ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden" com.bitwarden.project="setup"
RUN apt-get update \
@@ -8,8 +18,9 @@ RUN apt-get update \
gosu \
&& rm -rf /var/lib/apt/lists/*
+# Copy app from the build stage
WORKDIR /app
-COPY obj/build-output/publish .
+COPY --from=bitwarden-build /app/Setup ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
From 414272b6861d4cc861f5f51e92c661acb69d5ea9 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 18:16:36 -0500
Subject: [PATCH 020/184] Update platform strings
---
.github/workflows/build.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 146be04514..e8547b8244 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -196,7 +196,7 @@ jobs:
if-no-files-found: error
build:
- name: Build artifacts
+ name: Build projects
runs-on: ubuntu-22.04
# needs:
# - lint
@@ -249,7 +249,7 @@ jobs:
platforms: |
linux/amd64,
linux/arm/v7,
- linux/arm64/v8
+ linux/arm64
push: true
tags: ${{ steps.image-name.outputs.name }}
secrets: |
@@ -376,7 +376,7 @@ jobs:
platforms: |
linux/amd64,
linux/arm/v7,
- linux/arm64/v8
+ linux/arm64
push: true
tags: ${{ steps.image-name.outputs.name }}
secrets: |
From e7925f63e41e006cd13bd0ac474953a7cc2b5cde Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 9 Nov 2023 18:23:07 -0500
Subject: [PATCH 021/184] Fix MsSqlMigratorUtility project
---
build.Dockerfile | 2 ++
util/MsSqlMigratorUtility/Dockerfile | 17 ++++++++++++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/build.Dockerfile b/build.Dockerfile
index 2984e5a622..849531b83c 100644
--- a/build.Dockerfile
+++ b/build.Dockerfile
@@ -189,3 +189,5 @@ RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Server --no-restore --no
# Build Setup app
WORKDIR /source/util/Setup
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Setup --no-restore --no-self-contained -r $RID
+
+WORKDIR /app
diff --git a/util/MsSqlMigratorUtility/Dockerfile b/util/MsSqlMigratorUtility/Dockerfile
index 1a33ff12d2..11fab9a198 100644
--- a/util/MsSqlMigratorUtility/Dockerfile
+++ b/util/MsSqlMigratorUtility/Dockerfile
@@ -2,7 +2,22 @@ FROM mcr.microsoft.com/dotnet/aspnet:6.0
LABEL com.bitwarden.product="bitwarden"
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY util/MsSqlMigratorUtility/*.csproj ./util/MsSqlMigratorUtility/
+
+# Restore MsSqlMigratorUtility project dependencies and tools
+WORKDIR /source/util/MsSqlMigratorUtility
+RUN dotnet restore
+
+# Copy required project files
+WORKDIR /source
+COPY util/MsSqlMigratorUtility/. ./util/MsSqlMigratorUtility/
+
+# Build Setup app
+WORKDIR /source/util/MsSqlMigratorUtility
+RUN dotnet publish -c release -o /app/MsSqlMigratorUtility --no-restore --no-self-contained
+
WORKDIR /app
-COPY obj/build-output/publish .
ENTRYPOINT ["sh", "-c", "dotnet /app/MsSqlMigratorUtility.dll \"${MSSQL_CONN_STRING}\" -v ${@}", "--" ]
From 7e083e1173529cb16af7a716c0c9070a2b0d502d Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Mon, 13 Nov 2023 13:43:22 -0500
Subject: [PATCH 022/184] Fix copy command
---
util/MsSqlMigratorUtility/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/MsSqlMigratorUtility/Dockerfile b/util/MsSqlMigratorUtility/Dockerfile
index 11fab9a198..50aa1ba736 100644
--- a/util/MsSqlMigratorUtility/Dockerfile
+++ b/util/MsSqlMigratorUtility/Dockerfile
@@ -12,7 +12,7 @@ RUN dotnet restore
# Copy required project files
WORKDIR /source
-COPY util/MsSqlMigratorUtility/. ./util/MsSqlMigratorUtility/
+COPY . ./util/MsSqlMigratorUtility/
# Build Setup app
WORKDIR /source/util/MsSqlMigratorUtility
From 0444e9351b8c0fd0cd013c549ae8b9593434e01e Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Mon, 13 Nov 2023 16:08:10 -0500
Subject: [PATCH 023/184] Fix copy command
---
util/MsSqlMigratorUtility/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/MsSqlMigratorUtility/Dockerfile b/util/MsSqlMigratorUtility/Dockerfile
index 50aa1ba736..561d334088 100644
--- a/util/MsSqlMigratorUtility/Dockerfile
+++ b/util/MsSqlMigratorUtility/Dockerfile
@@ -4,7 +4,7 @@ LABEL com.bitwarden.product="bitwarden"
# Copy csproj files as distinct layers
WORKDIR /source
-COPY util/MsSqlMigratorUtility/*.csproj ./util/MsSqlMigratorUtility/
+COPY *.csproj ./util/MsSqlMigratorUtility/
# Restore MsSqlMigratorUtility project dependencies and tools
WORKDIR /source/util/MsSqlMigratorUtility
From 36e8341bc452030805fb0fb7585740dfc07fc29c Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 11:46:40 -0500
Subject: [PATCH 024/184] Update MsSqlMigratorUtility Docker file
---
util/MsSqlMigratorUtility/Dockerfile | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/util/MsSqlMigratorUtility/Dockerfile b/util/MsSqlMigratorUtility/Dockerfile
index 561d334088..133beb6fe7 100644
--- a/util/MsSqlMigratorUtility/Dockerfile
+++ b/util/MsSqlMigratorUtility/Dockerfile
@@ -1,6 +1,8 @@
-FROM mcr.microsoft.com/dotnet/aspnet:6.0
+###############################################
+# Build stage #
+###############################################
-LABEL com.bitwarden.product="bitwarden"
+FROM mcr.microsoft.com/dotnet/sdk:6.0 AS bitwarden-build
# Copy csproj files as distinct layers
WORKDIR /source
@@ -20,4 +22,15 @@ RUN dotnet publish -c release -o /app/MsSqlMigratorUtility --no-restore --no-sel
WORKDIR /app
+###############################################
+# App stage #
+###############################################
+FROM mcr.microsoft.com/dotnet/aspnet:6.0
+
+LABEL com.bitwarden.product="bitwarden"
+
+# Copy app from the build stage
+WORKDIR /app
+COPY --from=bitwarden-build /app/MsSqlMigratorUtility ./
+
ENTRYPOINT ["sh", "-c", "dotnet /app/MsSqlMigratorUtility.dll \"${MSSQL_CONN_STRING}\" -v ${@}", "--" ]
From 87c0c9742eac04c819fa3c91cdbe0efd5bc580a7 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 12:02:27 -0500
Subject: [PATCH 025/184] Add pull flag
---
.github/workflows/build.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e8547b8244..befb3ca69f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -377,6 +377,7 @@ jobs:
linux/amd64,
linux/arm/v7,
linux/arm64
+ pull: true
push: true
tags: ${{ steps.image-name.outputs.name }}
secrets: |
From 9dbac7975321be9a8f82335f0b6450034b9983dc Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 12:40:01 -0500
Subject: [PATCH 026/184] Change build to not use prod ACR for temp image
storage
---
.github/workflows/build.yml | 80 ++++++++++++++++-----------
bitwarden_license/src/Scim/Dockerfile | 2 +-
bitwarden_license/src/Sso/Dockerfile | 2 +-
src/Admin/Dockerfile | 2 +-
src/Api/Dockerfile | 2 +-
src/Billing/Dockerfile | 2 +-
src/Events/Dockerfile | 2 +-
src/EventsProcessor/Dockerfile | 2 +-
src/Icons/Dockerfile | 2 +-
src/Identity/Dockerfile | 2 +-
src/Notifications/Dockerfile | 2 +-
util/Attachments/Dockerfile | 2 +-
util/Server/Dockerfile | 2 +-
util/Setup/Dockerfile | 2 +-
14 files changed, 62 insertions(+), 44 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index befb3ca69f..1400dd9435 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -212,34 +212,34 @@ jobs:
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
########## ACRs ##########
- - name: Login to Azure - PROD Subscription
- uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
- with:
- creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
+ # - name: Login to Azure - PROD Subscription
+ # uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
+ # with:
+ # creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
- - name: Login to PROD ACR
- run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
+ # - name: Login to PROD ACR
+ # run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
- - name: Login to Azure - CI Subscription
- uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
- with:
- creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
+ # - name: Login to Azure - CI Subscription
+ # uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
+ # with:
+ # creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
- - name: Retrieve github PAT secrets
- id: retrieve-secret-pat
- uses: bitwarden/gh-actions/get-keyvault-secrets@main
- with:
- keyvault: "bitwarden-ci"
- secrets: "github-pat-bitwarden-devops-bot-repo-scope"
+ # - name: Retrieve github PAT secrets
+ # id: retrieve-secret-pat
+ # uses: bitwarden/gh-actions/get-keyvault-secrets@main
+ # with:
+ # keyvault: "bitwarden-ci"
+ # secrets: "github-pat-bitwarden-devops-bot-repo-scope"
- - name: Generate image full name
- id: image-name
- run: |
- IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g") # slash safe branch name
- if [[ "$IMAGE_TAG" == "master" ]]; then
- IMAGE_TAG=dev
- fi
- echo "name=${_AZ_REGISTRY}/build:${IMAGE_TAG}" >> $GITHUB_OUTPUT
+ # - name: Generate image full name
+ # id: image-name
+ # run: |
+ # IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g") # slash safe branch name
+ # if [[ "$IMAGE_TAG" == "master" ]]; then
+ # IMAGE_TAG=dev
+ # fi
+ # echo "name=${_AZ_REGISTRY}/build:${IMAGE_TAG}" >> $GITHUB_OUTPUT
- name: Build Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
@@ -250,10 +250,18 @@ jobs:
linux/amd64,
linux/arm/v7,
linux/arm64
- push: true
- tags: ${{ steps.image-name.outputs.name }}
- secrets: |
- "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
+ # push: true
+ outputs: type=docker,dest=/tmp/build.tar
+ # tags: ${{ steps.image-name.outputs.name }}
+ tags: build:latest
+ # secrets: |
+ # "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
+ with:
+ name: build
+ path: /tmp/build.tar
build-docker:
name: Build Docker images
@@ -366,18 +374,28 @@ jobs:
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
run: echo "name=${_AZ_REGISTRY}/${PROJECT_NAME}:${IMAGE_TAG}" >> $GITHUB_OUTPUT
+ - name: Download build image artifact
+ uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
+ with:
+ name: build
+ path: /tmp
+
+ - name: Load build image
+ run: |
+ docker load --input /tmp/build.tar
+ docker image ls -a
+
- name: Build Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
- build-args: |
- BUILD_TAG=${{ steps.tag.outputs.image_tag }}
+ # build-args: |
+ # BUILD_TAG=${{ steps.tag.outputs.image_tag }}
context: ${{ matrix.base_path }}/${{ matrix.project_name }}
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
platforms: |
linux/amd64,
linux/arm/v7,
linux/arm64
- pull: true
push: true
tags: ${{ steps.image-name.outputs.name }}
secrets: |
diff --git a/bitwarden_license/src/Scim/Dockerfile b/bitwarden_license/src/Scim/Dockerfile
index e96e000666..0d85d8a284 100644
--- a/bitwarden_license/src/Scim/Dockerfile
+++ b/bitwarden_license/src/Scim/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/bitwarden_license/src/Sso/Dockerfile b/bitwarden_license/src/Sso/Dockerfile
index e3927e2f12..0aad4442c0 100644
--- a/bitwarden_license/src/Sso/Dockerfile
+++ b/bitwarden_license/src/Sso/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 0d3b9578ba..07830a30b4 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/Api/Dockerfile b/src/Api/Dockerfile
index 7e5b68df7e..1a558c8e5d 100644
--- a/src/Api/Dockerfile
+++ b/src/Api/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/Billing/Dockerfile b/src/Billing/Dockerfile
index b651ea59f2..a0d9b16367 100644
--- a/src/Billing/Dockerfile
+++ b/src/Billing/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/Events/Dockerfile b/src/Events/Dockerfile
index 52f4f80390..b4f5bc3a03 100644
--- a/src/Events/Dockerfile
+++ b/src/Events/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/EventsProcessor/Dockerfile b/src/EventsProcessor/Dockerfile
index 15388a9ea9..ede264a2be 100644
--- a/src/EventsProcessor/Dockerfile
+++ b/src/EventsProcessor/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/Icons/Dockerfile b/src/Icons/Dockerfile
index 3cf662b55a..f5e578f532 100644
--- a/src/Icons/Dockerfile
+++ b/src/Icons/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/Identity/Dockerfile b/src/Identity/Dockerfile
index 83c822d2b2..8c52c8420a 100644
--- a/src/Identity/Dockerfile
+++ b/src/Identity/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/Notifications/Dockerfile b/src/Notifications/Dockerfile
index 633bc23802..3ca5c3ae53 100644
--- a/src/Notifications/Dockerfile
+++ b/src/Notifications/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/util/Attachments/Dockerfile b/util/Attachments/Dockerfile
index 4c620e994b..5c2b48c1f6 100644
--- a/util/Attachments/Dockerfile
+++ b/util/Attachments/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/util/Server/Dockerfile b/util/Server/Dockerfile
index b052a82ff0..e6380d5f00 100644
--- a/util/Server/Dockerfile
+++ b/util/Server/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/util/Setup/Dockerfile b/util/Setup/Dockerfile
index 99182f6d6a..2045d52de9 100644
--- a/util/Setup/Dockerfile
+++ b/util/Setup/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM bitwardenprod.azurecr.io/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
From 62248a90c2cfe76f5fb336bf37275b09033ae8b0 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 12:41:42 -0500
Subject: [PATCH 027/184] Change output type to oci
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1400dd9435..fd54b415cb 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -251,7 +251,7 @@ jobs:
linux/arm/v7,
linux/arm64
# push: true
- outputs: type=docker,dest=/tmp/build.tar
+ outputs: type=oci,dest=/tmp/build.tar
# tags: ${{ steps.image-name.outputs.name }}
tags: build:latest
# secrets: |
From 7601822fd4639c9d97f0a2be1260450fbebd83e2 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 13:10:14 -0500
Subject: [PATCH 028/184] Change version of upload-artifact action to v3.1.2
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index fd54b415cb..bf181d1d72 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -258,7 +258,7 @@ jobs:
# "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
- name: Upload artifact
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
+ uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: build
path: /tmp/build.tar
From 8a606c600c65057a1f2c299ea2104e684897453f Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 13:52:20 -0500
Subject: [PATCH 029/184] Change to Azure storage account
---
.github/workflows/build.yml | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index bf181d1d72..ebd92c220e 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -220,10 +220,10 @@ jobs:
# - name: Login to PROD ACR
# run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
- # - name: Login to Azure - CI Subscription
- # uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
- # with:
- # creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
+ - name: Login to Azure - CI Subscription
+ uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
+ with:
+ creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
# - name: Retrieve github PAT secrets
# id: retrieve-secret-pat
@@ -258,10 +258,12 @@ jobs:
# "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
- name: Upload artifact
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
- with:
- name: build
- path: /tmp/build.tar
+ run: |
+ az storage blob upload \
+ --file /tmp/build.tar \
+ --container-name builds \
+ --name build \
+ --account-name dockerimagetest
build-docker:
name: Build Docker images
@@ -380,6 +382,15 @@ jobs:
name: build
path: /tmp
+ - name: Download build image artifact
+ run: |
+ az storage blob download \
+ --file /tmp/build.tar \
+ --container-name builds \
+ --name build \
+ --account-name dockerimagetest
+ ls -alh /tmp
+
- name: Load build image
run: |
docker load --input /tmp/build.tar
From d1bcdf22833ab7fc18da0e4a0f21a0bdf5c97af1 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 14:07:59 -0500
Subject: [PATCH 030/184] Add storage account upload test
---
.github/workflows/build.yml | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index ebd92c220e..0d8eb20aa5 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -225,12 +225,23 @@ jobs:
with:
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
- # - name: Retrieve github PAT secrets
- # id: retrieve-secret-pat
- # uses: bitwarden/gh-actions/get-keyvault-secrets@main
- # with:
- # keyvault: "bitwarden-ci"
- # secrets: "github-pat-bitwarden-devops-bot-repo-scope"
+ - name: Retrieve Storage Account secret
+ id: retrieve-secret
+ uses: bitwarden/gh-actions/get-keyvault-secrets@main
+ with:
+ keyvault: "bitwarden-ci"
+ secrets: "storage-account-dockerimagetest-conn-string"
+
+ - name: TEST - Upload artifact
+ run: |
+ echo "Test file" > /tmp/test.txt
+ az storage blob upload \
+ --file /tmp/test.txt \
+ --container-name builds \
+ --name build \
+ --connection-string ${{ steps.retrieve-secret.outputs.storage-account-dockerimagetest-conn-string}}
+
+
# - name: Generate image full name
# id: image-name
From 5f6d443fe84199ee7339c547b7930591cdd03638 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 14:15:30 -0500
Subject: [PATCH 031/184] Test
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0d8eb20aa5..abd62ec6e9 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -239,7 +239,7 @@ jobs:
--file /tmp/test.txt \
--container-name builds \
--name build \
- --connection-string ${{ steps.retrieve-secret.outputs.storage-account-dockerimagetest-conn-string}}
+ --connection-string ${{ env.storage-account-dockerimagetest-conn-string }}
From 2740dbc4941ff530917dd51c136fc95579eb603d Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 14:17:23 -0500
Subject: [PATCH 032/184] Test
---
.github/workflows/build.yml | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index abd62ec6e9..7bbe66643a 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -235,11 +235,7 @@ jobs:
- name: TEST - Upload artifact
run: |
echo "Test file" > /tmp/test.txt
- az storage blob upload \
- --file /tmp/test.txt \
- --container-name builds \
- --name build \
- --connection-string ${{ env.storage-account-dockerimagetest-conn-string }}
+ az storage blob upload --file /tmp/test.txt --container-name builds --name build --connection-string ${{ env.storage-account-dockerimagetest-conn-string }}
From f853411e191873f404024f123ad76dbcabef3ca7 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 14:20:19 -0500
Subject: [PATCH 033/184] Test
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7bbe66643a..cd907d2875 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -235,7 +235,7 @@ jobs:
- name: TEST - Upload artifact
run: |
echo "Test file" > /tmp/test.txt
- az storage blob upload --file /tmp/test.txt --container-name builds --name build --connection-string ${{ env.storage-account-dockerimagetest-conn-string }}
+ az storage blob upload --file /tmp/test.txt --container-name builds --name build --connection-string "${{ env.storage-account-dockerimagetest-conn-string }}"
From c595a2cf6e3c10de9977e49ba672c2e796d4d1a5 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 14:21:41 -0500
Subject: [PATCH 034/184] Test
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index cd907d2875..58613d042c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -235,7 +235,7 @@ jobs:
- name: TEST - Upload artifact
run: |
echo "Test file" > /tmp/test.txt
- az storage blob upload --file /tmp/test.txt --container-name builds --name build --connection-string "${{ env.storage-account-dockerimagetest-conn-string }}"
+ az storage blob upload --file /tmp/test.txt --container-name builds --name build --connection-string '${{ env.storage-account-dockerimagetest-conn-string }}'
From 5e0c7fdf46d41ef26bd2d8d6085de4faea51fe6f Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 14:24:46 -0500
Subject: [PATCH 035/184] Test
---
.github/workflows/build.yml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 58613d042c..abd62ec6e9 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -235,7 +235,11 @@ jobs:
- name: TEST - Upload artifact
run: |
echo "Test file" > /tmp/test.txt
- az storage blob upload --file /tmp/test.txt --container-name builds --name build --connection-string '${{ env.storage-account-dockerimagetest-conn-string }}'
+ az storage blob upload \
+ --file /tmp/test.txt \
+ --container-name builds \
+ --name build \
+ --connection-string ${{ env.storage-account-dockerimagetest-conn-string }}
From bccdccba003bba69485eb865b4ecf6fc356257ca Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 14:25:58 -0500
Subject: [PATCH 036/184] Test
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index abd62ec6e9..6d0e5aa1f1 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -239,7 +239,7 @@ jobs:
--file /tmp/test.txt \
--container-name builds \
--name build \
- --connection-string ${{ env.storage-account-dockerimagetest-conn-string }}
+ --connection-string '${{ env.storage-account-dockerimagetest-conn-string }}'
From 44edd6ed5f60bbf83b91a0f5d090543c508976cc Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 14:29:34 -0500
Subject: [PATCH 037/184] Fix upload
---
.github/workflows/build.yml | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 6d0e5aa1f1..3747e1e121 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -231,17 +231,6 @@ jobs:
with:
keyvault: "bitwarden-ci"
secrets: "storage-account-dockerimagetest-conn-string"
-
- - name: TEST - Upload artifact
- run: |
- echo "Test file" > /tmp/test.txt
- az storage blob upload \
- --file /tmp/test.txt \
- --container-name builds \
- --name build \
- --connection-string '${{ env.storage-account-dockerimagetest-conn-string }}'
-
-
# - name: Generate image full name
# id: image-name
@@ -270,11 +259,12 @@ jobs:
- name: Upload artifact
run: |
+ ls -alh /tmp
az storage blob upload \
--file /tmp/build.tar \
--container-name builds \
--name build \
- --account-name dockerimagetest
+ --connection-string '${{ env.storage-account-dockerimagetest-conn-string }}'
build-docker:
name: Build Docker images
From 942b516ebfb0a7c6fa9c0cd893591663f848ea33 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 14:42:48 -0500
Subject: [PATCH 038/184] Test download
---
.github/workflows/build.yml | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 3747e1e121..9b937d5d25 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -196,6 +196,7 @@ jobs:
if-no-files-found: error
build:
+ if: false
name: Build projects
runs-on: ubuntu-22.04
# needs:
@@ -269,8 +270,8 @@ jobs:
build-docker:
name: Build Docker images
runs-on: ubuntu-22.04
- needs:
- - build
+ # needs:
+ # - build
strategy:
fail-fast: false
matrix:
@@ -345,12 +346,12 @@ jobs:
with:
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
- - name: Retrieve github PAT secrets
- id: retrieve-secret-pat
+ - name: Retrieve Storage Account secret
+ id: retrieve-secret
uses: bitwarden/gh-actions/get-keyvault-secrets@main
with:
keyvault: "bitwarden-ci"
- secrets: "github-pat-bitwarden-devops-bot-repo-scope"
+ secrets: "storage-account-dockerimagetest-conn-string"
########## Generate image tag and build Docker image ##########
- name: Generate Docker image tag
@@ -377,19 +378,13 @@ jobs:
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
run: echo "name=${_AZ_REGISTRY}/${PROJECT_NAME}:${IMAGE_TAG}" >> $GITHUB_OUTPUT
- - name: Download build image artifact
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
- with:
- name: build
- path: /tmp
-
- name: Download build image artifact
run: |
az storage blob download \
--file /tmp/build.tar \
--container-name builds \
--name build \
- --account-name dockerimagetest
+ --connection-string '${{ env.storage-account-dockerimagetest-conn-string }}'
ls -alh /tmp
- name: Load build image
@@ -410,8 +405,6 @@ jobs:
linux/arm64
push: true
tags: ${{ steps.image-name.outputs.name }}
- secrets: |
- "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
- name: Log out of Docker
run: docker logout
From 5143e411b548d63bc15eafc61526ca789505d8cb Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 14:51:49 -0500
Subject: [PATCH 039/184] Test other method
---
.github/workflows/build.yml | 39 +++++++++++++--------------
bitwarden_license/src/Scim/Dockerfile | 2 +-
bitwarden_license/src/Sso/Dockerfile | 2 +-
src/Admin/Dockerfile | 2 +-
src/Api/Dockerfile | 2 +-
src/Billing/Dockerfile | 2 +-
src/Events/Dockerfile | 2 +-
src/EventsProcessor/Dockerfile | 2 +-
src/Icons/Dockerfile | 2 +-
src/Identity/Dockerfile | 2 +-
src/Notifications/Dockerfile | 2 +-
util/Attachments/Dockerfile | 2 +-
util/Server/Dockerfile | 2 +-
util/Setup/Dockerfile | 2 +-
14 files changed, 31 insertions(+), 34 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 9b937d5d25..7ace23d7c9 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -272,6 +272,11 @@ jobs:
runs-on: ubuntu-22.04
# needs:
# - build
+ services:
+ registry:
+ image: registry:2
+ ports:
+ - 5000:5000
strategy:
fail-fast: false
matrix:
@@ -346,14 +351,20 @@ jobs:
with:
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
- - name: Retrieve Storage Account secret
- id: retrieve-secret
- uses: bitwarden/gh-actions/get-keyvault-secrets@main
- with:
- keyvault: "bitwarden-ci"
- secrets: "storage-account-dockerimagetest-conn-string"
-
########## Generate image tag and build Docker image ##########
+ - name: Build Docker image
+ uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
+ with:
+ context: .
+ file: build.Dockerfile
+ platforms: |
+ linux/amd64,
+ linux/arm/v7,
+ linux/arm64
+ push: true
+ outputs: type=oci,dest=/tmp/build.tar
+ tags: localhost:5000/build:latest
+
- name: Generate Docker image tag
id: tag
run: |
@@ -378,20 +389,6 @@ jobs:
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
run: echo "name=${_AZ_REGISTRY}/${PROJECT_NAME}:${IMAGE_TAG}" >> $GITHUB_OUTPUT
- - name: Download build image artifact
- run: |
- az storage blob download \
- --file /tmp/build.tar \
- --container-name builds \
- --name build \
- --connection-string '${{ env.storage-account-dockerimagetest-conn-string }}'
- ls -alh /tmp
-
- - name: Load build image
- run: |
- docker load --input /tmp/build.tar
- docker image ls -a
-
- name: Build Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
diff --git a/bitwarden_license/src/Scim/Dockerfile b/bitwarden_license/src/Scim/Dockerfile
index 0d85d8a284..969c4855c7 100644
--- a/bitwarden_license/src/Scim/Dockerfile
+++ b/bitwarden_license/src/Scim/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/bitwarden_license/src/Sso/Dockerfile b/bitwarden_license/src/Sso/Dockerfile
index 0aad4442c0..31241acb11 100644
--- a/bitwarden_license/src/Sso/Dockerfile
+++ b/bitwarden_license/src/Sso/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 07830a30b4..537b615156 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/Api/Dockerfile b/src/Api/Dockerfile
index 1a558c8e5d..496db58cd8 100644
--- a/src/Api/Dockerfile
+++ b/src/Api/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/Billing/Dockerfile b/src/Billing/Dockerfile
index a0d9b16367..ebed93b8dd 100644
--- a/src/Billing/Dockerfile
+++ b/src/Billing/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/Events/Dockerfile b/src/Events/Dockerfile
index b4f5bc3a03..7b1df8467d 100644
--- a/src/Events/Dockerfile
+++ b/src/Events/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/EventsProcessor/Dockerfile b/src/EventsProcessor/Dockerfile
index ede264a2be..1ab3c727e2 100644
--- a/src/EventsProcessor/Dockerfile
+++ b/src/EventsProcessor/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/Icons/Dockerfile b/src/Icons/Dockerfile
index f5e578f532..6bc21ffd4b 100644
--- a/src/Icons/Dockerfile
+++ b/src/Icons/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/Identity/Dockerfile b/src/Identity/Dockerfile
index 8c52c8420a..7821c32a04 100644
--- a/src/Identity/Dockerfile
+++ b/src/Identity/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/src/Notifications/Dockerfile b/src/Notifications/Dockerfile
index 3ca5c3ae53..0a02a14dee 100644
--- a/src/Notifications/Dockerfile
+++ b/src/Notifications/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/util/Attachments/Dockerfile b/util/Attachments/Dockerfile
index 5c2b48c1f6..51837dc455 100644
--- a/util/Attachments/Dockerfile
+++ b/util/Attachments/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/util/Server/Dockerfile b/util/Server/Dockerfile
index e6380d5f00..4e425d2111 100644
--- a/util/Server/Dockerfile
+++ b/util/Server/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
diff --git a/util/Setup/Dockerfile b/util/Setup/Dockerfile
index 2045d52de9..4901b59f15 100644
--- a/util/Setup/Dockerfile
+++ b/util/Setup/Dockerfile
@@ -2,7 +2,7 @@
# Build stage #
###############################################
ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
###############################################
# App stage #
From 82cd28e6c057875bcaa4b965382aca50cf794767 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 14:53:37 -0500
Subject: [PATCH 040/184] Remove output
---
.github/workflows/build.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7ace23d7c9..dbb0210388 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -362,7 +362,6 @@ jobs:
linux/arm/v7,
linux/arm64
push: true
- outputs: type=oci,dest=/tmp/build.tar
tags: localhost:5000/build:latest
- name: Generate Docker image tag
From d21717e1d5e2fb3a091266c96371a68914f7ce60 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 15:40:15 -0500
Subject: [PATCH 041/184] Move all build steps to project Dockerfiles
---
.github/workflows/build.yml | 102 +-------------------------
bitwarden_license/src/Scim/Dockerfile | 43 ++++++++++-
bitwarden_license/src/Sso/Dockerfile | 43 ++++++++++-
src/Admin/Dockerfile | 55 +++++++++++++-
src/Api/Dockerfile | 47 +++++++++++-
src/Billing/Dockerfile | 43 ++++++++++-
src/Events/Dockerfile | 43 ++++++++++-
src/EventsProcessor/Dockerfile | 43 ++++++++++-
src/Icons/Dockerfile | 43 ++++++++++-
src/Identity/Dockerfile | 55 +++++++++++++-
src/Notifications/Dockerfile | 43 ++++++++++-
util/Attachments/Dockerfile | 39 +++++++++-
util/Server/Dockerfile | 39 +++++++++-
util/Setup/Dockerfile | 40 +++++++++-
14 files changed, 540 insertions(+), 138 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index dbb0210388..aad4b44d19 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -195,88 +195,9 @@ jobs:
path: ${{ matrix.base_path }}/${{ matrix.project_name }}/${{ matrix.project_name }}.zip
if-no-files-found: error
- build:
- if: false
- name: Build projects
- runs-on: ubuntu-22.04
- # needs:
- # - lint
- # - testing
- steps:
- - name: Checkout repo
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
-
- - name: Set up QEMU emulators
- uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
-
- ########## ACRs ##########
- # - name: Login to Azure - PROD Subscription
- # uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
- # with:
- # creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
-
- # - name: Login to PROD ACR
- # run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
-
- - name: Login to Azure - CI Subscription
- uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
- with:
- creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
-
- - name: Retrieve Storage Account secret
- id: retrieve-secret
- uses: bitwarden/gh-actions/get-keyvault-secrets@main
- with:
- keyvault: "bitwarden-ci"
- secrets: "storage-account-dockerimagetest-conn-string"
-
- # - name: Generate image full name
- # id: image-name
- # run: |
- # IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g") # slash safe branch name
- # if [[ "$IMAGE_TAG" == "master" ]]; then
- # IMAGE_TAG=dev
- # fi
- # echo "name=${_AZ_REGISTRY}/build:${IMAGE_TAG}" >> $GITHUB_OUTPUT
-
- - name: Build Docker image
- uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
- with:
- context: .
- file: build.Dockerfile
- platforms: |
- linux/amd64,
- linux/arm/v7,
- linux/arm64
- # push: true
- outputs: type=oci,dest=/tmp/build.tar
- # tags: ${{ steps.image-name.outputs.name }}
- tags: build:latest
- # secrets: |
- # "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
-
- - name: Upload artifact
- run: |
- ls -alh /tmp
- az storage blob upload \
- --file /tmp/build.tar \
- --container-name builds \
- --name build \
- --connection-string '${{ env.storage-account-dockerimagetest-conn-string }}'
-
build-docker:
name: Build Docker images
runs-on: ubuntu-22.04
- # needs:
- # - build
- services:
- registry:
- image: registry:2
- ports:
- - 5000:5000
strategy:
fail-fast: false
matrix:
@@ -346,24 +267,7 @@ jobs:
- name: Login to PROD ACR
run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
- - name: Login to Azure - CI Subscription
- uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
- with:
- creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
-
########## Generate image tag and build Docker image ##########
- - name: Build Docker image
- uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
- with:
- context: .
- file: build.Dockerfile
- platforms: |
- linux/amd64,
- linux/arm/v7,
- linux/arm64
- push: true
- tags: localhost:5000/build:latest
-
- name: Generate Docker image tag
id: tag
run: |
@@ -391,9 +295,9 @@ jobs:
- name: Build Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
- # build-args: |
- # BUILD_TAG=${{ steps.tag.outputs.image_tag }}
- context: ${{ matrix.base_path }}/${{ matrix.project_name }}
+ build-args: |
+ BUILD_TAG=${{ steps.tag.outputs.image_tag }}
+ context: .
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
platforms: |
linux/amd64,
diff --git a/bitwarden_license/src/Scim/Dockerfile b/bitwarden_license/src/Scim/Dockerfile
index 969c4855c7..d3d8cf53e7 100644
--- a/bitwarden_license/src/Scim/Dockerfile
+++ b/bitwarden_license/src/Scim/Dockerfile
@@ -1,8 +1,45 @@
###############################################
# Build stage #
###############################################
-ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY bitwarden_license/src/Scim/*.csproj ./bitwarden_license/src/Scim/
+COPY src/Core/*.csproj ./src/Core/
+COPY src/SharedWeb/*.csproj ./src/SharedWeb/
+COPY Directory.Build.props .
+
+# Restore Scim project dependencies and tools
+WORKDIR /source/bitwarden_license/src/Scim
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Copy required project files
+WORKDIR /source
+COPY bitwarden_license/src/Scim/. ./bitwarden_license/src/Scim/
+COPY src/Core/. ./src/Core/
+COPY src/SharedWeb/. ./src/SharedWeb/
+# COPY .git/. ./.git/
+
+# Build Scim app
+WORKDIR /source/bitwarden_license/src/Scim
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Scim --no-restore --no-self-contained -r $RID
+
+WORKDIR /app
###############################################
# App stage #
@@ -23,7 +60,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
-COPY --from=bitwarden-build /app/Scim ./
+COPY --from=build /app/Scim ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/bitwarden_license/src/Sso/Dockerfile b/bitwarden_license/src/Sso/Dockerfile
index 31241acb11..a505f045cb 100644
--- a/bitwarden_license/src/Sso/Dockerfile
+++ b/bitwarden_license/src/Sso/Dockerfile
@@ -1,8 +1,45 @@
###############################################
# Build stage #
###############################################
-ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY bitwarden_license/src/Sso/*.csproj ./bitwarden_license/src/Sso/
+COPY src/Core/*.csproj ./src/Core/
+COPY src/SharedWeb/*.csproj ./src/SharedWeb/
+COPY Directory.Build.props .
+
+# Restore Sso project dependencies and tools
+WORKDIR /source/bitwarden_license/src/Sso
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Copy required project files
+WORKDIR /source
+COPY bitwarden_license/src/Sso/. ./bitwarden_license/src/Sso/
+COPY src/Core/. ./src/Core/
+COPY src/SharedWeb/. ./src/SharedWeb/
+# COPY .git/. ./.git/
+
+# Build Sso app
+WORKDIR /source/bitwarden_license/src/Sso
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Sso --no-restore --no-self-contained -r $RID
+
+WORKDIR /app
###############################################
# App stage #
@@ -23,7 +60,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
-COPY --from=bitwarden-build /app/Sso ./
+COPY --from=build /app/Sso ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 537b615156..e9732cdd9c 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -1,8 +1,57 @@
###############################################
# Build stage #
###############################################
-ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY src/Admin/*.csproj ./src/Admin/
+COPY src/Core/*.csproj ./src/Core/
+COPY src/SharedWeb/*.csproj ./src/SharedWeb/
+COPY util/Migrator/*.csproj ./util/Migrator/
+COPY util/MySqlMigrations/*.csproj ./util/MySqlMigrations/
+COPY util/PostgresMigrations/*.csproj ./util/PostgresMigrations/
+COPY util/SqliteMigrations/*.csproj ./util/SqliteMigrations/
+COPY bitwarden_license/src/Commercial.Core/*.csproj ./bitwarden_license/src/Commercial.Core/
+COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/*.csproj ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
+COPY Directory.Build.props .
+
+# Restore Admin project dependencies and tools
+WORKDIR /source/src/Admin
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Copy required project files
+WORKDIR /source
+COPY src/Admin/. ./src/Admin/
+COPY src/Core/. ./src/Core/
+COPY src/SharedWeb/. ./src/SharedWeb/
+COPY util/Migrator/. ./util/Migrator/
+COPY util/MySqlMigrations/. ./util/MySqlMigrations/
+COPY util/PostgresMigrations/. ./util/PostgresMigrations/
+COPY util/SqliteMigrations/. ./util/SqliteMigrations/
+COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
+COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
+# COPY .git/. ./.git/
+
+# Build Admin app
+WORKDIR /source/src/Admin
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Admin --no-restore --no-self-contained -r $RID
+
+WORKDIR /app
###############################################
# App stage #
@@ -23,7 +72,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
-COPY --from=bitwarden-build /app/Admin ./
+COPY --from=build /app/Admin ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/src/Api/Dockerfile b/src/Api/Dockerfile
index 496db58cd8..c93a24a0af 100644
--- a/src/Api/Dockerfile
+++ b/src/Api/Dockerfile
@@ -1,8 +1,49 @@
###############################################
# Build stage #
###############################################
-ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY src/Api/*.csproj ./src/Api/
+COPY src/Core/*.csproj ./src/Core/
+COPY src/SharedWeb/*.csproj ./src/SharedWeb/
+COPY bitwarden_license/src/Commercial.Core/*.csproj ./bitwarden_license/src/Commercial.Core/
+COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/*.csproj ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
+COPY Directory.Build.props .
+
+# Restore Api project dependencies and tools
+WORKDIR /source/src/Api
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Copy required project files
+WORKDIR /source
+COPY src/Api/. ./src/Api/
+COPY src/Core/. ./src/Core/
+COPY src/SharedWeb/. ./src/SharedWeb/
+COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
+COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
+# COPY .git/. ./.git/
+
+# Build Api app
+WORKDIR /source/src/Api
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Api --no-restore --no-self-contained -r $RID
+
+WORKDIR /app
###############################################
# App stage #
@@ -23,7 +64,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
-COPY --from=bitwarden-build /app/Api ./
+COPY --from=build /app/Api ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/src/Billing/Dockerfile b/src/Billing/Dockerfile
index ebed93b8dd..c94514d89b 100644
--- a/src/Billing/Dockerfile
+++ b/src/Billing/Dockerfile
@@ -1,8 +1,45 @@
###############################################
# Build stage #
###############################################
-ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY src/Billing/*.csproj ./src/Billing/
+COPY src/Core/*.csproj ./src/Core/
+COPY src/SharedWeb/*.csproj ./src/SharedWeb/
+COPY Directory.Build.props .
+
+# Restore Billing project dependencies and tools
+WORKDIR /source/src/Billing
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Copy required project files
+WORKDIR /source
+COPY src/Billing/. ./src/Billing/
+COPY src/Core/. ./src/Core/
+COPY src/SharedWeb/. ./src/SharedWeb/
+# COPY .git/. ./.git/
+
+# Build Billing app
+WORKDIR /source/src/Billing
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Billing --no-restore --no-self-contained -r $RID
+
+WORKDIR /app
###############################################
# App stage #
@@ -23,7 +60,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
-COPY --from=bitwarden-build /app/Billing ./
+COPY --from=build /app/Billing ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/src/Events/Dockerfile b/src/Events/Dockerfile
index 7b1df8467d..d6f81f759a 100644
--- a/src/Events/Dockerfile
+++ b/src/Events/Dockerfile
@@ -1,8 +1,45 @@
###############################################
# Build stage #
###############################################
-ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY src/Events/*.csproj ./src/Events/
+COPY src/Core/*.csproj ./src/Core/
+COPY src/SharedWeb/*.csproj ./src/SharedWeb/
+COPY Directory.Build.props .
+
+# Restore Events project dependencies and tools
+WORKDIR /source/src/Events
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Copy required project files
+WORKDIR /source
+COPY src/Events/. ./src/Events/
+COPY src/Core/. ./src/Core/
+COPY src/SharedWeb/. ./src/SharedWeb/
+# COPY .git/. ./.git/
+
+# Build Events app
+WORKDIR /source/src/Events
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Events --no-restore --no-self-contained -r $RID
+
+WORKDIR /app
###############################################
# App stage #
@@ -23,7 +60,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
-COPY --from=bitwarden-build /app/Admin ./
+COPY --from=build /app/Admin ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/src/EventsProcessor/Dockerfile b/src/EventsProcessor/Dockerfile
index 1ab3c727e2..292109b87b 100644
--- a/src/EventsProcessor/Dockerfile
+++ b/src/EventsProcessor/Dockerfile
@@ -1,8 +1,45 @@
###############################################
# Build stage #
###############################################
-ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY src/EventsProcessor/*.csproj ./src/EventsProcessor/
+COPY src/Core/*.csproj ./src/Core/
+COPY src/SharedWeb/*.csproj ./src/SharedWeb/
+COPY Directory.Build.props .
+
+# Restore EventsProcessor project dependencies and tools
+WORKDIR /source/src/EventsProcessor
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Copy required project files
+WORKDIR /source
+COPY src/EventsProcessor/. ./src/EventsProcessor/
+COPY src/Core/. ./src/Core/
+COPY src/SharedWeb/. ./src/SharedWeb/
+# COPY .git/. ./.git/
+
+# Build EventsProcessor app
+WORKDIR /source/src/EventsProcessor
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/EventsProcessor --no-restore --no-self-contained -r $RID
+
+WORKDIR /app
###############################################
# App stage #
@@ -23,7 +60,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
-COPY --from=bitwarden-build /app/EventsProcessor ./
+COPY --from=build /app/EventsProcessor ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/src/Icons/Dockerfile b/src/Icons/Dockerfile
index 6bc21ffd4b..aaca787180 100644
--- a/src/Icons/Dockerfile
+++ b/src/Icons/Dockerfile
@@ -1,8 +1,45 @@
###############################################
# Build stage #
###############################################
-ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY src/Icons/*.csproj ./src/Icons/
+COPY src/Core/*.csproj ./src/Core/
+COPY src/SharedWeb/*.csproj ./src/SharedWeb/
+COPY Directory.Build.props .
+
+# Restore Icons project dependencies and tools
+WORKDIR /source/src/Icons
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Copy required project files
+WORKDIR /source
+COPY src/Icons/. ./src/Icons/
+COPY src/Core/. ./src/Core/
+COPY src/SharedWeb/. ./src/SharedWeb/
+# COPY .git/. ./.git/
+
+# Build Icons app
+WORKDIR /source/src/Icons
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Icons --no-restore --no-self-contained -r $RID
+
+WORKDIR /app
###############################################
# App stage #
@@ -23,7 +60,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
-COPY --from=bitwarden-build /app/Icons ./
+COPY --from=build /app/Icons ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/src/Identity/Dockerfile b/src/Identity/Dockerfile
index 7821c32a04..27adc2cdf2 100644
--- a/src/Identity/Dockerfile
+++ b/src/Identity/Dockerfile
@@ -1,8 +1,57 @@
###############################################
# Build stage #
###############################################
-ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY src/Admin/*.csproj ./src/Admin/
+COPY src/Core/*.csproj ./src/Core/
+COPY src/SharedWeb/*.csproj ./src/SharedWeb/
+COPY util/Migrator/*.csproj ./util/Migrator/
+COPY util/MySqlMigrations/*.csproj ./util/MySqlMigrations/
+COPY util/PostgresMigrations/*.csproj ./util/PostgresMigrations/
+COPY util/SqliteMigrations/*.csproj ./util/SqliteMigrations/
+COPY bitwarden_license/src/Commercial.Core/*.csproj ./bitwarden_license/src/Commercial.Core/
+COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/*.csproj ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
+COPY Directory.Build.props .
+
+# Restore Admin project dependencies and tools
+WORKDIR /source/src/Admin
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Copy required project files
+WORKDIR /source
+COPY src/Admin/. ./src/Admin/
+COPY src/Core/. ./src/Core/
+COPY src/SharedWeb/. ./src/SharedWeb/
+COPY util/Migrator/. ./util/Migrator/
+COPY util/MySqlMigrations/. ./util/MySqlMigrations/
+COPY util/PostgresMigrations/. ./util/PostgresMigrations/
+COPY util/SqliteMigrations/. ./util/SqliteMigrations/
+COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
+COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
+# COPY .git/. ./.git/
+
+# Build Admin app
+WORKDIR /source/src/Admin
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Admin --no-restore --no-self-contained -r $RID
+
+WORKDIR /app
###############################################
# App stage #
@@ -23,7 +72,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
-COPY --from=bitwarden-build /app/Identity ./
+COPY --from=build /app/Identity ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/src/Notifications/Dockerfile b/src/Notifications/Dockerfile
index 0a02a14dee..bd8fcbd840 100644
--- a/src/Notifications/Dockerfile
+++ b/src/Notifications/Dockerfile
@@ -1,8 +1,45 @@
###############################################
# Build stage #
###############################################
-ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY src/Core/*.csproj ./src/Core/
+COPY src/Notifications/*.csproj ./src/Notifications/
+COPY src/SharedWeb/*.csproj ./src/SharedWeb/
+COPY Directory.Build.props .
+
+# Restore Notifications project dependencies and tools
+WORKDIR /source/src/Notifications
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Copy required project files
+WORKDIR /source
+COPY src/Core/. ./src/Core/
+COPY src/Notifications/. ./src/Notifications/
+COPY src/SharedWeb/. ./src/SharedWeb/
+# COPY .git/. ./.git/
+
+# Build Notifications app
+WORKDIR /source/src/Notifications
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Notifications --no-restore --no-self-contained -r $RID
+
+WORKDIR /app
###############################################
# App stage #
@@ -23,7 +60,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
-COPY --from=bitwarden-build /app/Notifications ./
+COPY --from=build /app/Notifications ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/util/Attachments/Dockerfile b/util/Attachments/Dockerfile
index 51837dc455..a67028a08c 100644
--- a/util/Attachments/Dockerfile
+++ b/util/Attachments/Dockerfile
@@ -1,8 +1,41 @@
###############################################
# Build stage #
###############################################
-ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY util/Server/*.csproj ./util/Server/
+COPY Directory.Build.props .
+
+# Restore Server project dependencies and tools
+WORKDIR /source/util/Server
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Copy required project files
+WORKDIR /source
+COPY util/Server/. ./util/Server/
+# COPY .git/. ./.git/
+
+# Build Server app
+WORKDIR /source/util/Server
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Server --no-restore --no-self-contained -r $RID
+
+WORKDIR /app
###############################################
# App stage #
@@ -23,7 +56,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /bitwarden_server
-COPY --from=bitwarden-build /app/Server ./
+COPY --from=build /app/Server ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/util/Server/Dockerfile b/util/Server/Dockerfile
index 4e425d2111..052b298785 100644
--- a/util/Server/Dockerfile
+++ b/util/Server/Dockerfile
@@ -1,8 +1,41 @@
###############################################
# Build stage #
###############################################
-ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY util/Server/*.csproj ./util/Server/
+COPY Directory.Build.props .
+
+# Restore Server project dependencies and tools
+WORKDIR /source/util/Server
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Copy required project files
+WORKDIR /source
+COPY util/Server/. ./util/Server/
+# COPY .git/. ./.git/
+
+# Build Server app
+WORKDIR /source/util/Server
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Server --no-restore --no-self-contained -r $RID
+
+WORKDIR /app
###############################################
# App stage #
@@ -13,4 +46,4 @@ LABEL com.bitwarden.product="bitwarden"
# Copy app from the build stage
WORKDIR /bitwarden_server
-COPY --from=bitwarden-build /app/Server ./
\ No newline at end of file
+COPY --from=build /app/Server ./
\ No newline at end of file
diff --git a/util/Setup/Dockerfile b/util/Setup/Dockerfile
index 4901b59f15..e385706208 100644
--- a/util/Setup/Dockerfile
+++ b/util/Setup/Dockerfile
@@ -1,8 +1,42 @@
###############################################
# Build stage #
###############################################
-ARG BUILD_TAG=latest
-FROM --platform=$BUILDPLATFORM localhost:5000/build:${BUILD_TAG} AS bitwarden-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
+
+# Copy csproj files as distinct layers
+WORKDIR /source
+COPY util/Migrator/*.csproj ./util/Migrator/
+COPY util/Setup/*.csproj ./util/Setup/
+COPY Directory.Build.props .
+
+# Restore Setup project dependencies and tools
+WORKDIR /source/util/Setup
+RUN . /tmp/rid.txt && dotnet restore -r $RID
+
+# Copy required project files
+WORKDIR /source
+COPY util/Setup/. ./util/Setup/
+# COPY .git/. ./.git/
+
+# Build Setup app
+WORKDIR /source/util/Setup
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Setup --no-restore --no-self-contained -r $RID
+
+WORKDIR /app
###############################################
# App stage #
@@ -20,7 +54,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
-COPY --from=bitwarden-build /app/Setup ./
+COPY --from=build /app/Setup ./
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
From edad0e1edf62a88d742d45f74e75f71e31c14072 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 15:44:20 -0500
Subject: [PATCH 042/184] Fix copy commands in Dockerfiles
---
bitwarden_license/src/Scim/Dockerfile | 2 +-
bitwarden_license/src/Sso/Dockerfile | 2 +-
src/Admin/Dockerfile | 2 +-
src/Api/Dockerfile | 2 +-
src/Billing/Dockerfile | 2 +-
src/Events/Dockerfile | 2 +-
src/EventsProcessor/Dockerfile | 2 +-
src/Icons/Dockerfile | 2 +-
src/Identity/Dockerfile | 2 +-
src/Notifications/Dockerfile | 2 +-
util/Attachments/Dockerfile | 2 +-
util/Setup/Dockerfile | 2 +-
12 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/bitwarden_license/src/Scim/Dockerfile b/bitwarden_license/src/Scim/Dockerfile
index d3d8cf53e7..d3ca2f2c26 100644
--- a/bitwarden_license/src/Scim/Dockerfile
+++ b/bitwarden_license/src/Scim/Dockerfile
@@ -61,7 +61,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
COPY --from=build /app/Scim ./
-COPY entrypoint.sh /
+COPY bitwarden_license/src/Scim/entrypoint.sh /
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000/alive || exit 1
diff --git a/bitwarden_license/src/Sso/Dockerfile b/bitwarden_license/src/Sso/Dockerfile
index a505f045cb..d79c7abe15 100644
--- a/bitwarden_license/src/Sso/Dockerfile
+++ b/bitwarden_license/src/Sso/Dockerfile
@@ -61,7 +61,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
COPY --from=build /app/Sso ./
-COPY entrypoint.sh /
+COPY bitwarden_license/src/Sso/entrypoint.sh /
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000/alive || exit 1
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index e9732cdd9c..a5015dc8b3 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -73,7 +73,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
COPY --from=build /app/Admin ./
-COPY entrypoint.sh /
+COPY src/Admin/entrypoint.sh /
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000 || exit 1
diff --git a/src/Api/Dockerfile b/src/Api/Dockerfile
index c93a24a0af..ab5f9ccb31 100644
--- a/src/Api/Dockerfile
+++ b/src/Api/Dockerfile
@@ -65,7 +65,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
COPY --from=build /app/Api ./
-COPY entrypoint.sh /
+COPY src/Api/entrypoint.sh /
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000/alive || exit 1
diff --git a/src/Billing/Dockerfile b/src/Billing/Dockerfile
index c94514d89b..8c2fbbabaf 100644
--- a/src/Billing/Dockerfile
+++ b/src/Billing/Dockerfile
@@ -61,7 +61,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
COPY --from=build /app/Billing ./
-COPY entrypoint.sh /
+COPY src/Billing/entrypoint.sh /
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000/alive || exit 1
diff --git a/src/Events/Dockerfile b/src/Events/Dockerfile
index d6f81f759a..18ba2a334d 100644
--- a/src/Events/Dockerfile
+++ b/src/Events/Dockerfile
@@ -61,7 +61,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
COPY --from=build /app/Admin ./
-COPY entrypoint.sh /
+COPY src/Events/entrypoint.sh /
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000/alive || exit 1
diff --git a/src/EventsProcessor/Dockerfile b/src/EventsProcessor/Dockerfile
index 292109b87b..b6a02073b4 100644
--- a/src/EventsProcessor/Dockerfile
+++ b/src/EventsProcessor/Dockerfile
@@ -61,7 +61,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
COPY --from=build /app/EventsProcessor ./
-COPY entrypoint.sh /
+COPY src/EventsProcessor/entrypoint.sh /
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000/alive || exit 1
diff --git a/src/Icons/Dockerfile b/src/Icons/Dockerfile
index aaca787180..ddc19ff14c 100644
--- a/src/Icons/Dockerfile
+++ b/src/Icons/Dockerfile
@@ -61,7 +61,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
COPY --from=build /app/Icons ./
-COPY entrypoint.sh /
+COPY src/Icons/entrypoint.sh /
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000/google.com/icon.png || exit 1
diff --git a/src/Identity/Dockerfile b/src/Identity/Dockerfile
index 27adc2cdf2..99d9910e4d 100644
--- a/src/Identity/Dockerfile
+++ b/src/Identity/Dockerfile
@@ -73,7 +73,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
COPY --from=build /app/Identity ./
-COPY entrypoint.sh /
+COPY src/Identity/entrypoint.sh /
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000/.well-known/openid-configuration || exit 1
diff --git a/src/Notifications/Dockerfile b/src/Notifications/Dockerfile
index bd8fcbd840..136fc9be36 100644
--- a/src/Notifications/Dockerfile
+++ b/src/Notifications/Dockerfile
@@ -61,7 +61,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
COPY --from=build /app/Notifications ./
-COPY entrypoint.sh /
+COPY src/Notifications/entrypoint.sh /
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000/alive || exit 1
diff --git a/util/Attachments/Dockerfile b/util/Attachments/Dockerfile
index a67028a08c..0f8c19013a 100644
--- a/util/Attachments/Dockerfile
+++ b/util/Attachments/Dockerfile
@@ -57,7 +57,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /bitwarden_server
COPY --from=build /app/Server ./
-COPY entrypoint.sh /
+COPY util/Attachments/entrypoint.sh /
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000/alive || exit 1
diff --git a/util/Setup/Dockerfile b/util/Setup/Dockerfile
index e385706208..61db604339 100644
--- a/util/Setup/Dockerfile
+++ b/util/Setup/Dockerfile
@@ -55,7 +55,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
COPY --from=build /app/Setup ./
-COPY entrypoint.sh /
+COPY util/Setup/entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
From 41050091f639ecd07ddbb1d9b680b80e261af2d7 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 15:47:03 -0500
Subject: [PATCH 043/184] Uncomment .git copy
---
bitwarden_license/src/Scim/Dockerfile | 2 +-
bitwarden_license/src/Sso/Dockerfile | 2 +-
src/Admin/Dockerfile | 2 +-
src/Api/Dockerfile | 2 +-
src/Billing/Dockerfile | 2 +-
src/Events/Dockerfile | 2 +-
src/EventsProcessor/Dockerfile | 2 +-
src/Icons/Dockerfile | 2 +-
src/Identity/Dockerfile | 2 +-
src/Notifications/Dockerfile | 2 +-
util/Attachments/Dockerfile | 2 +-
util/Server/Dockerfile | 2 +-
util/Setup/Dockerfile | 2 +-
13 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/bitwarden_license/src/Scim/Dockerfile b/bitwarden_license/src/Scim/Dockerfile
index d3ca2f2c26..1c666403a1 100644
--- a/bitwarden_license/src/Scim/Dockerfile
+++ b/bitwarden_license/src/Scim/Dockerfile
@@ -33,7 +33,7 @@ WORKDIR /source
COPY bitwarden_license/src/Scim/. ./bitwarden_license/src/Scim/
COPY src/Core/. ./src/Core/
COPY src/SharedWeb/. ./src/SharedWeb/
-# COPY .git/. ./.git/
+COPY .git/. ./.git/
# Build Scim app
WORKDIR /source/bitwarden_license/src/Scim
diff --git a/bitwarden_license/src/Sso/Dockerfile b/bitwarden_license/src/Sso/Dockerfile
index d79c7abe15..da4270b22e 100644
--- a/bitwarden_license/src/Sso/Dockerfile
+++ b/bitwarden_license/src/Sso/Dockerfile
@@ -33,7 +33,7 @@ WORKDIR /source
COPY bitwarden_license/src/Sso/. ./bitwarden_license/src/Sso/
COPY src/Core/. ./src/Core/
COPY src/SharedWeb/. ./src/SharedWeb/
-# COPY .git/. ./.git/
+COPY .git/. ./.git/
# Build Sso app
WORKDIR /source/bitwarden_license/src/Sso
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index a5015dc8b3..ec10df9c47 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -45,7 +45,7 @@ COPY util/PostgresMigrations/. ./util/PostgresMigrations/
COPY util/SqliteMigrations/. ./util/SqliteMigrations/
COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
-# COPY .git/. ./.git/
+COPY .git/. ./.git/
# Build Admin app
WORKDIR /source/src/Admin
diff --git a/src/Api/Dockerfile b/src/Api/Dockerfile
index ab5f9ccb31..d7342debdd 100644
--- a/src/Api/Dockerfile
+++ b/src/Api/Dockerfile
@@ -37,7 +37,7 @@ COPY src/Core/. ./src/Core/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
-# COPY .git/. ./.git/
+COPY .git/. ./.git/
# Build Api app
WORKDIR /source/src/Api
diff --git a/src/Billing/Dockerfile b/src/Billing/Dockerfile
index 8c2fbbabaf..e2d9f9fd7c 100644
--- a/src/Billing/Dockerfile
+++ b/src/Billing/Dockerfile
@@ -33,7 +33,7 @@ WORKDIR /source
COPY src/Billing/. ./src/Billing/
COPY src/Core/. ./src/Core/
COPY src/SharedWeb/. ./src/SharedWeb/
-# COPY .git/. ./.git/
+COPY .git/. ./.git/
# Build Billing app
WORKDIR /source/src/Billing
diff --git a/src/Events/Dockerfile b/src/Events/Dockerfile
index 18ba2a334d..74b38a1797 100644
--- a/src/Events/Dockerfile
+++ b/src/Events/Dockerfile
@@ -33,7 +33,7 @@ WORKDIR /source
COPY src/Events/. ./src/Events/
COPY src/Core/. ./src/Core/
COPY src/SharedWeb/. ./src/SharedWeb/
-# COPY .git/. ./.git/
+COPY .git/. ./.git/
# Build Events app
WORKDIR /source/src/Events
diff --git a/src/EventsProcessor/Dockerfile b/src/EventsProcessor/Dockerfile
index b6a02073b4..a6b7cf62bc 100644
--- a/src/EventsProcessor/Dockerfile
+++ b/src/EventsProcessor/Dockerfile
@@ -33,7 +33,7 @@ WORKDIR /source
COPY src/EventsProcessor/. ./src/EventsProcessor/
COPY src/Core/. ./src/Core/
COPY src/SharedWeb/. ./src/SharedWeb/
-# COPY .git/. ./.git/
+COPY .git/. ./.git/
# Build EventsProcessor app
WORKDIR /source/src/EventsProcessor
diff --git a/src/Icons/Dockerfile b/src/Icons/Dockerfile
index ddc19ff14c..a3f76e62f7 100644
--- a/src/Icons/Dockerfile
+++ b/src/Icons/Dockerfile
@@ -33,7 +33,7 @@ WORKDIR /source
COPY src/Icons/. ./src/Icons/
COPY src/Core/. ./src/Core/
COPY src/SharedWeb/. ./src/SharedWeb/
-# COPY .git/. ./.git/
+COPY .git/. ./.git/
# Build Icons app
WORKDIR /source/src/Icons
diff --git a/src/Identity/Dockerfile b/src/Identity/Dockerfile
index 99d9910e4d..c0daab573a 100644
--- a/src/Identity/Dockerfile
+++ b/src/Identity/Dockerfile
@@ -45,7 +45,7 @@ COPY util/PostgresMigrations/. ./util/PostgresMigrations/
COPY util/SqliteMigrations/. ./util/SqliteMigrations/
COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
-# COPY .git/. ./.git/
+COPY .git/. ./.git/
# Build Admin app
WORKDIR /source/src/Admin
diff --git a/src/Notifications/Dockerfile b/src/Notifications/Dockerfile
index 136fc9be36..46ab2a89e1 100644
--- a/src/Notifications/Dockerfile
+++ b/src/Notifications/Dockerfile
@@ -33,7 +33,7 @@ WORKDIR /source
COPY src/Core/. ./src/Core/
COPY src/Notifications/. ./src/Notifications/
COPY src/SharedWeb/. ./src/SharedWeb/
-# COPY .git/. ./.git/
+COPY .git/. ./.git/
# Build Notifications app
WORKDIR /source/src/Notifications
diff --git a/util/Attachments/Dockerfile b/util/Attachments/Dockerfile
index 0f8c19013a..4270972f71 100644
--- a/util/Attachments/Dockerfile
+++ b/util/Attachments/Dockerfile
@@ -29,7 +29,7 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
# Copy required project files
WORKDIR /source
COPY util/Server/. ./util/Server/
-# COPY .git/. ./.git/
+COPY .git/. ./.git/
# Build Server app
WORKDIR /source/util/Server
diff --git a/util/Server/Dockerfile b/util/Server/Dockerfile
index 052b298785..8b78751ca1 100644
--- a/util/Server/Dockerfile
+++ b/util/Server/Dockerfile
@@ -29,7 +29,7 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
# Copy required project files
WORKDIR /source
COPY util/Server/. ./util/Server/
-# COPY .git/. ./.git/
+COPY .git/. ./.git/
# Build Server app
WORKDIR /source/util/Server
diff --git a/util/Setup/Dockerfile b/util/Setup/Dockerfile
index 61db604339..2c5a85eea0 100644
--- a/util/Setup/Dockerfile
+++ b/util/Setup/Dockerfile
@@ -30,7 +30,7 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
# Copy required project files
WORKDIR /source
COPY util/Setup/. ./util/Setup/
-# COPY .git/. ./.git/
+COPY .git/. ./.git/
# Build Setup app
WORKDIR /source/util/Setup
From bd13dd64acfea44c8b699fe7b5ca9b24b48aff37 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 15:54:24 -0500
Subject: [PATCH 044/184] Fix project imports
---
bitwarden_license/src/Scim/Dockerfile | 4 ++++
bitwarden_license/src/Sso/Dockerfile | 4 ++++
src/Admin/Dockerfile | 4 ++++
src/Api/Dockerfile | 4 ++++
src/Billing/Dockerfile | 4 ++++
src/Events/Dockerfile | 4 ++++
src/EventsProcessor/Dockerfile | 4 ++++
src/Icons/Dockerfile | 4 ++++
src/Identity/Dockerfile | 4 ++++
src/Notifications/Dockerfile | 4 ++++
10 files changed, 40 insertions(+)
diff --git a/bitwarden_license/src/Scim/Dockerfile b/bitwarden_license/src/Scim/Dockerfile
index 1c666403a1..0c97fdcf49 100644
--- a/bitwarden_license/src/Scim/Dockerfile
+++ b/bitwarden_license/src/Scim/Dockerfile
@@ -21,6 +21,8 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
WORKDIR /source
COPY bitwarden_license/src/Scim/*.csproj ./bitwarden_license/src/Scim/
COPY src/Core/*.csproj ./src/Core/
+COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
@@ -32,6 +34,8 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
WORKDIR /source
COPY bitwarden_license/src/Scim/. ./bitwarden_license/src/Scim/
COPY src/Core/. ./src/Core/
+COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
diff --git a/bitwarden_license/src/Sso/Dockerfile b/bitwarden_license/src/Sso/Dockerfile
index da4270b22e..439ffd4f04 100644
--- a/bitwarden_license/src/Sso/Dockerfile
+++ b/bitwarden_license/src/Sso/Dockerfile
@@ -21,6 +21,8 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
WORKDIR /source
COPY bitwarden_license/src/Sso/*.csproj ./bitwarden_license/src/Sso/
COPY src/Core/*.csproj ./src/Core/
+COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
@@ -32,6 +34,8 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
WORKDIR /source
COPY bitwarden_license/src/Sso/. ./bitwarden_license/src/Sso/
COPY src/Core/. ./src/Core/
+COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index ec10df9c47..644f10f0ce 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -21,6 +21,8 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
WORKDIR /source
COPY src/Admin/*.csproj ./src/Admin/
COPY src/Core/*.csproj ./src/Core/
+COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY util/Migrator/*.csproj ./util/Migrator/
COPY util/MySqlMigrations/*.csproj ./util/MySqlMigrations/
@@ -38,6 +40,8 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
WORKDIR /source
COPY src/Admin/. ./src/Admin/
COPY src/Core/. ./src/Core/
+COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY util/Migrator/. ./util/Migrator/
COPY util/MySqlMigrations/. ./util/MySqlMigrations/
diff --git a/src/Api/Dockerfile b/src/Api/Dockerfile
index d7342debdd..0f6e70ff86 100644
--- a/src/Api/Dockerfile
+++ b/src/Api/Dockerfile
@@ -21,6 +21,8 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
WORKDIR /source
COPY src/Api/*.csproj ./src/Api/
COPY src/Core/*.csproj ./src/Core/
+COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY bitwarden_license/src/Commercial.Core/*.csproj ./bitwarden_license/src/Commercial.Core/
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/*.csproj ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
@@ -34,6 +36,8 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
WORKDIR /source
COPY src/Api/. ./src/Api/
COPY src/Core/. ./src/Core/
+COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
diff --git a/src/Billing/Dockerfile b/src/Billing/Dockerfile
index e2d9f9fd7c..58258f5730 100644
--- a/src/Billing/Dockerfile
+++ b/src/Billing/Dockerfile
@@ -21,6 +21,8 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
WORKDIR /source
COPY src/Billing/*.csproj ./src/Billing/
COPY src/Core/*.csproj ./src/Core/
+COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
@@ -32,6 +34,8 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
WORKDIR /source
COPY src/Billing/. ./src/Billing/
COPY src/Core/. ./src/Core/
+COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
diff --git a/src/Events/Dockerfile b/src/Events/Dockerfile
index 74b38a1797..0cdc099f2c 100644
--- a/src/Events/Dockerfile
+++ b/src/Events/Dockerfile
@@ -21,6 +21,8 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
WORKDIR /source
COPY src/Events/*.csproj ./src/Events/
COPY src/Core/*.csproj ./src/Core/
+COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
@@ -32,6 +34,8 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
WORKDIR /source
COPY src/Events/. ./src/Events/
COPY src/Core/. ./src/Core/
+COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
diff --git a/src/EventsProcessor/Dockerfile b/src/EventsProcessor/Dockerfile
index a6b7cf62bc..7b67dffb7f 100644
--- a/src/EventsProcessor/Dockerfile
+++ b/src/EventsProcessor/Dockerfile
@@ -21,6 +21,8 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
WORKDIR /source
COPY src/EventsProcessor/*.csproj ./src/EventsProcessor/
COPY src/Core/*.csproj ./src/Core/
+COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
@@ -32,6 +34,8 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
WORKDIR /source
COPY src/EventsProcessor/. ./src/EventsProcessor/
COPY src/Core/. ./src/Core/
+COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
diff --git a/src/Icons/Dockerfile b/src/Icons/Dockerfile
index a3f76e62f7..384f75410d 100644
--- a/src/Icons/Dockerfile
+++ b/src/Icons/Dockerfile
@@ -21,6 +21,8 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
WORKDIR /source
COPY src/Icons/*.csproj ./src/Icons/
COPY src/Core/*.csproj ./src/Core/
+COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
@@ -32,6 +34,8 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
WORKDIR /source
COPY src/Icons/. ./src/Icons/
COPY src/Core/. ./src/Core/
+COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
diff --git a/src/Identity/Dockerfile b/src/Identity/Dockerfile
index c0daab573a..dec0b6d0a0 100644
--- a/src/Identity/Dockerfile
+++ b/src/Identity/Dockerfile
@@ -21,6 +21,8 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
WORKDIR /source
COPY src/Admin/*.csproj ./src/Admin/
COPY src/Core/*.csproj ./src/Core/
+COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY util/Migrator/*.csproj ./util/Migrator/
COPY util/MySqlMigrations/*.csproj ./util/MySqlMigrations/
@@ -38,6 +40,8 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
WORKDIR /source
COPY src/Admin/. ./src/Admin/
COPY src/Core/. ./src/Core/
+COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY util/Migrator/. ./util/Migrator/
COPY util/MySqlMigrations/. ./util/MySqlMigrations/
diff --git a/src/Notifications/Dockerfile b/src/Notifications/Dockerfile
index 46ab2a89e1..b257fcb367 100644
--- a/src/Notifications/Dockerfile
+++ b/src/Notifications/Dockerfile
@@ -21,6 +21,8 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
WORKDIR /source
COPY src/Core/*.csproj ./src/Core/
COPY src/Notifications/*.csproj ./src/Notifications/
+COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
@@ -32,6 +34,8 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
WORKDIR /source
COPY src/Core/. ./src/Core/
COPY src/Notifications/. ./src/Notifications/
+COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
+COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
From 9381577f6647481a594ca36e2055b5e513f09ae8 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 16:05:05 -0500
Subject: [PATCH 045/184] Fix Dockerfiles
---
src/Admin/Dockerfile | 1 +
src/Events/Dockerfile | 2 +-
src/Identity/Dockerfile | 1 +
util/MsSql/Dockerfile | 6 +++---
util/MsSqlMigratorUtility/Dockerfile | 4 ++--
util/Nginx/Dockerfile | 14 +++++++-------
util/Setup/Dockerfile | 1 +
7 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 644f10f0ce..37e523a4fe 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -47,6 +47,7 @@ COPY util/Migrator/. ./util/Migrator/
COPY util/MySqlMigrations/. ./util/MySqlMigrations/
COPY util/PostgresMigrations/. ./util/PostgresMigrations/
COPY util/SqliteMigrations/. ./util/SqliteMigrations/
+COPY util/EfShared/. ./util/EfShared/
COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
COPY .git/. ./.git/
diff --git a/src/Events/Dockerfile b/src/Events/Dockerfile
index 0cdc099f2c..2833c860f9 100644
--- a/src/Events/Dockerfile
+++ b/src/Events/Dockerfile
@@ -64,7 +64,7 @@ RUN apt-get update \
# Copy app from the build stage
WORKDIR /app
-COPY --from=build /app/Admin ./
+COPY --from=build /app/Events ./
COPY src/Events/entrypoint.sh /
RUN chmod +x /entrypoint.sh
diff --git a/src/Identity/Dockerfile b/src/Identity/Dockerfile
index dec0b6d0a0..3e9fb769aa 100644
--- a/src/Identity/Dockerfile
+++ b/src/Identity/Dockerfile
@@ -47,6 +47,7 @@ COPY util/Migrator/. ./util/Migrator/
COPY util/MySqlMigrations/. ./util/MySqlMigrations/
COPY util/PostgresMigrations/. ./util/PostgresMigrations/
COPY util/SqliteMigrations/. ./util/SqliteMigrations/
+COPY util/EfShared/. ./util/EfShared/
COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
COPY .git/. ./.git/
diff --git a/util/MsSql/Dockerfile b/util/MsSql/Dockerfile
index 330f78208f..572a2b8007 100644
--- a/util/MsSql/Dockerfile
+++ b/util/MsSql/Dockerfile
@@ -10,9 +10,9 @@ RUN apt-get update \
tzdata \
&& rm -rf /var/lib/apt/lists/*
-COPY backup-db.sql /
-COPY backup-db.sh /
-COPY entrypoint.sh /
+COPY util/MsSql/backup-db.sql /
+COPY util/MsSql/backup-db.sh /
+COPY util/MsSql/entrypoint.sh /
RUN chmod +x /entrypoint.sh \
&& chmod +x /backup-db.sh
diff --git a/util/MsSqlMigratorUtility/Dockerfile b/util/MsSqlMigratorUtility/Dockerfile
index 133beb6fe7..815a53011d 100644
--- a/util/MsSqlMigratorUtility/Dockerfile
+++ b/util/MsSqlMigratorUtility/Dockerfile
@@ -6,7 +6,7 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS bitwarden-build
# Copy csproj files as distinct layers
WORKDIR /source
-COPY *.csproj ./util/MsSqlMigratorUtility/
+COPY util/MsSqlMigratorUtility/*.csproj ./util/MsSqlMigratorUtility/
# Restore MsSqlMigratorUtility project dependencies and tools
WORKDIR /source/util/MsSqlMigratorUtility
@@ -14,7 +14,7 @@ RUN dotnet restore
# Copy required project files
WORKDIR /source
-COPY . ./util/MsSqlMigratorUtility/
+COPY util/MsSqlMigratorUtility/. ./util/MsSqlMigratorUtility/
# Build Setup app
WORKDIR /source/util/MsSqlMigratorUtility
diff --git a/util/Nginx/Dockerfile b/util/Nginx/Dockerfile
index 973b616efb..7f85b77ea6 100644
--- a/util/Nginx/Dockerfile
+++ b/util/Nginx/Dockerfile
@@ -9,13 +9,13 @@ RUN apt-get update \
curl \
&& rm -rf /var/lib/apt/lists/*
-COPY nginx.conf /etc/nginx
-COPY proxy.conf /etc/nginx
-COPY mime.types /etc/nginx
-COPY security-headers.conf /etc/nginx
-COPY security-headers-ssl.conf /etc/nginx
-COPY logrotate.sh /
-COPY entrypoint.sh /
+COPY util/Nginx/nginx.conf /etc/nginx
+COPY util/Nginx/proxy.conf /etc/nginx
+COPY util/Nginx/mime.types /etc/nginx
+COPY util/Nginx/security-headers.conf /etc/nginx
+COPY util/Nginx/security-headers-ssl.conf /etc/nginx
+COPY util/Nginx/logrotate.sh /
+COPY util/Nginx/entrypoint.sh /
EXPOSE 8080
EXPOSE 8443
diff --git a/util/Setup/Dockerfile b/util/Setup/Dockerfile
index 2c5a85eea0..34570ecae8 100644
--- a/util/Setup/Dockerfile
+++ b/util/Setup/Dockerfile
@@ -29,6 +29,7 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
# Copy required project files
WORKDIR /source
+COPY util/Migrator/. ./util/Migrator/
COPY util/Setup/. ./util/Setup/
COPY .git/. ./.git/
From e8e7820ef6d0f473df3d0a77fd0653ccb4f988c1 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 16:13:49 -0500
Subject: [PATCH 046/184] Fix Dockerfiles
---
src/Identity/Dockerfile | 27 +++++++--------------------
util/Setup/Dockerfile | 2 ++
2 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/src/Identity/Dockerfile b/src/Identity/Dockerfile
index 3e9fb769aa..cbcc32413e 100644
--- a/src/Identity/Dockerfile
+++ b/src/Identity/Dockerfile
@@ -19,42 +19,29 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
# Copy csproj files as distinct layers
WORKDIR /source
-COPY src/Admin/*.csproj ./src/Admin/
+COPY src/Identity/*.csproj ./src/Identity/
COPY src/Core/*.csproj ./src/Core/
COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
-COPY util/Migrator/*.csproj ./util/Migrator/
-COPY util/MySqlMigrations/*.csproj ./util/MySqlMigrations/
-COPY util/PostgresMigrations/*.csproj ./util/PostgresMigrations/
-COPY util/SqliteMigrations/*.csproj ./util/SqliteMigrations/
-COPY bitwarden_license/src/Commercial.Core/*.csproj ./bitwarden_license/src/Commercial.Core/
-COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/*.csproj ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
COPY Directory.Build.props .
-# Restore Admin project dependencies and tools
-WORKDIR /source/src/Admin
+# Restore Identity project dependencies and tools
+WORKDIR /source/src/Identity
RUN . /tmp/rid.txt && dotnet restore -r $RID
# Copy required project files
WORKDIR /source
-COPY src/Admin/. ./src/Admin/
+COPY src/Identity/. ./src/Identity/
COPY src/Core/. ./src/Core/
COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
-COPY util/Migrator/. ./util/Migrator/
-COPY util/MySqlMigrations/. ./util/MySqlMigrations/
-COPY util/PostgresMigrations/. ./util/PostgresMigrations/
-COPY util/SqliteMigrations/. ./util/SqliteMigrations/
-COPY util/EfShared/. ./util/EfShared/
-COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
-COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
COPY .git/. ./.git/
-# Build Admin app
-WORKDIR /source/src/Admin
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Admin --no-restore --no-self-contained -r $RID
+# Build Identity app
+WORKDIR /source/src/Identity
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Identity --no-restore --no-self-contained -r $RID
WORKDIR /app
diff --git a/util/Setup/Dockerfile b/util/Setup/Dockerfile
index 34570ecae8..dce42a14bb 100644
--- a/util/Setup/Dockerfile
+++ b/util/Setup/Dockerfile
@@ -19,6 +19,7 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
# Copy csproj files as distinct layers
WORKDIR /source
+COPY src/Core/*.csproj ./src/Core/
COPY util/Migrator/*.csproj ./util/Migrator/
COPY util/Setup/*.csproj ./util/Setup/
COPY Directory.Build.props .
@@ -29,6 +30,7 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
# Copy required project files
WORKDIR /source
+COPY src/Core/. ./src/Core/
COPY util/Migrator/. ./util/Migrator/
COPY util/Setup/. ./util/Setup/
COPY .git/. ./.git/
From 586bac8018ee84aaea75532a8f5ccb6b0e242455 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 17:34:11 -0500
Subject: [PATCH 047/184] Fix gulp for Admin/Sso
---
bitwarden_license/src/Sso/Dockerfile | 22 ++++++++++++++++++++++
src/Admin/Dockerfile | 22 ++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/bitwarden_license/src/Sso/Dockerfile b/bitwarden_license/src/Sso/Dockerfile
index 439ffd4f04..784647dee2 100644
--- a/bitwarden_license/src/Sso/Dockerfile
+++ b/bitwarden_license/src/Sso/Dockerfile
@@ -5,6 +5,8 @@ FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
# Docker buildx supplies the value for this arg
ARG TARGETPLATFORM
+ENV NODE_VERSION=16.20.2
+ENV NVM_DIR /usr/local/nvm
# Determine proper runtime value for .NET
# We put the value in a file to be read by later layers.
@@ -17,6 +19,24 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
fi \
&& echo "RID=$RID" > /tmp/rid.txt
+# Add packages
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ curl \
+ && rm -rf /var/lib/apt/lists/*
+
+# Set up Node
+RUN mkdir -p $NVM_DIR
+RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
+ && . $NVM_DIR/nvm.sh \
+ && nvm install $NODE_VERSION \
+ && nvm alias default $NODE_VERSION \
+ && nvm use default
+ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
+ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
+
+# Install gulp
+RUN npm install -g gulp
+
# Copy csproj files as distinct layers
WORKDIR /source
COPY bitwarden_license/src/Sso/*.csproj ./bitwarden_license/src/Sso/
@@ -41,6 +61,8 @@ COPY .git/. ./.git/
# Build Sso app
WORKDIR /source/bitwarden_license/src/Sso
+RUN npm install
+RUN gulp --gulpfile "gulpfile.js" build
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Sso --no-restore --no-self-contained -r $RID
WORKDIR /app
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 37e523a4fe..20930d774e 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -5,6 +5,8 @@ FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
# Docker buildx supplies the value for this arg
ARG TARGETPLATFORM
+ARG NODE_VERSION=16.20.2
+ENV NVM_DIR /usr/local/nvm
# Determine proper runtime value for .NET
# We put the value in a file to be read by later layers.
@@ -17,6 +19,24 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
fi \
&& echo "RID=$RID" > /tmp/rid.txt
+# Add packages
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ curl \
+ && rm -rf /var/lib/apt/lists/*
+
+# Set up Node
+RUN mkdir -p $NVM_DIR
+RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
+ && . $NVM_DIR/nvm.sh \
+ && nvm install $NODE_VERSION \
+ && nvm alias default $NODE_VERSION \
+ && nvm use default
+ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
+ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
+
+# Install gulp
+RUN npm install -g gulp
+
# Copy csproj files as distinct layers
WORKDIR /source
COPY src/Admin/*.csproj ./src/Admin/
@@ -54,6 +74,8 @@ COPY .git/. ./.git/
# Build Admin app
WORKDIR /source/src/Admin
+RUN npm install
+RUN gulp --gulpfile "gulpfile.js" build
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Admin --no-restore --no-self-contained -r $RID
WORKDIR /app
From 1100ee58d70433b8e3ed83c6c1176351df571e02 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 18:08:24 -0500
Subject: [PATCH 048/184] Remove Dockerfile-k8s
---
util/Nginx/Dockerfile-k8s | 40 ---------------------------------------
1 file changed, 40 deletions(-)
delete mode 100644 util/Nginx/Dockerfile-k8s
diff --git a/util/Nginx/Dockerfile-k8s b/util/Nginx/Dockerfile-k8s
deleted file mode 100644
index 9f0d89ee1d..0000000000
--- a/util/Nginx/Dockerfile-k8s
+++ /dev/null
@@ -1,40 +0,0 @@
-FROM nginx:stable
-
-LABEL com.bitwarden.product="bitwarden"
-
-ENV USERNAME="bitwarden"
-ENV GROUPNAME="bitwarden"
-
-RUN apt-get update && \
- apt-get install -y --no-install-recommends \
- gosu \
- curl && \
- rm -rf /var/lib/apt/lists/*
-
-COPY nginx.conf /etc/nginx/nginx.conf
-COPY proxy.conf /etc/nginx/proxy.conf
-COPY mime.types /etc/nginx/mime.types
-COPY security-headers.conf /etc/nginx/security-headers.conf
-COPY security-headers-ssl.conf /etc/nginx/security-headers.conf
-
-COPY setup-bwuser.sh /
-
-EXPOSE 8000
-
-EXPOSE 8080
-EXPOSE 8443
-
-RUN chmod +x /setup-bwuser.sh
-
-RUN ./setup-bwuser.sh $USERNAME $GROUPNAME
-
-RUN mkdir -p /var/run/nginx && \
- touch /var/run/nginx/nginx.pid
-RUN chown -R $USERNAME:$GROUPNAME /var/run/nginx && \
- chown -R $USERNAME:$GROUPNAME /var/cache/nginx && \
- chown -R $USERNAME:$GROUPNAME /var/log/nginx
-
-
-HEALTHCHECK CMD curl --insecure -Lfs https://localhost:8443/alive || curl -Lfs http://localhost:8080/alive || exit 1
-
-USER bitwarden
From 18d297e4e31e7c85f05f226a93923bcacf6108d3 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 18:11:41 -0500
Subject: [PATCH 049/184] Remove extra build.Dockerfile
---
build.Dockerfile | 193 -----------------------------------------------
1 file changed, 193 deletions(-)
delete mode 100644 build.Dockerfile
diff --git a/build.Dockerfile b/build.Dockerfile
deleted file mode 100644
index 849531b83c..0000000000
--- a/build.Dockerfile
+++ /dev/null
@@ -1,193 +0,0 @@
-###############################################
-# Build stage #
-###############################################
-FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0
-
-# Docker buildx supplies the value for this arg
-ARG TARGETPLATFORM
-ENV NODE_VERSION=16.20.2
-ENV NVM_DIR /usr/local/nvm
-
-# Determine proper runtime value for .NET
-# We put the value in a file to be read by later layers.
-RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
- RID=linux-x64 ; \
- elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
- RID=linux-arm64 ; \
- elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
- RID=linux-arm ; \
- fi \
- && echo "RID=$RID" > /tmp/rid.txt
-
-# Add packages
-RUN apt-get update && apt-get install -y --no-install-recommends \
- curl \
- && rm -rf /var/lib/apt/lists/*
-
-# Set up Node
-RUN mkdir -p $NVM_DIR
-RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
- && . $NVM_DIR/nvm.sh \
- && nvm install $NODE_VERSION \
- && nvm alias default $NODE_VERSION \
- && nvm use default
-ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
-ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
-
-# Install gulp
-RUN npm install -g gulp
-
-# Copy csproj files as distinct layers
-WORKDIR /source
-COPY src/Admin/*.csproj ./src/Admin/
-COPY src/Api/*.csproj ./src/Api/
-COPY src/Billing/*.csproj ./src/Billing/
-COPY src/Events/*.csproj ./src/Events/
-COPY src/EventsProcessor/*.csproj ./src/EventsProcessor/
-COPY src/Icons/*.csproj ./src/Icons/
-COPY src/Identity/*.csproj ./src/Identity/
-COPY src/Notifications/*.csproj ./src/Notifications/
-COPY bitwarden_license/src/Sso/*.csproj ./bitwarden_license/src/Sso/
-COPY bitwarden_license/src/Scim/*.csproj ./bitwarden_license/src/Scim/
-COPY src/Core/*.csproj ./src/Core/
-COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
-COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
-COPY src/SharedWeb/*.csproj ./src/SharedWeb/
-COPY util/Migrator/*.csproj ./util/Migrator/
-COPY util/MySqlMigrations/*.csproj ./util/MySqlMigrations/
-COPY util/PostgresMigrations/*.csproj ./util/PostgresMigrations/
-COPY util/Server/*.csproj ./util/Server/
-COPY util/Setup/*.csproj ./util/Setup/
-COPY util/SqliteMigrations/*.csproj ./util/SqliteMigrations/
-COPY bitwarden_license/src/Commercial.Core/*.csproj ./bitwarden_license/src/Commercial.Core/
-COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/*.csproj ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
-COPY Directory.Build.props .
-
-# Restore Admin project dependencies and tools
-WORKDIR /source/src/Admin
-RUN . /tmp/rid.txt && dotnet restore -r $RID
-
-# Restore Api project dependencies and tools
-WORKDIR /source/src/Api
-RUN . /tmp/rid.txt && dotnet restore -r $RID
-
-# Restore Billing project dependencies and tools
-WORKDIR /source/src/Billing
-RUN . /tmp/rid.txt && dotnet restore -r $RID
-
-# Restore Events project dependencies and tools
-WORKDIR /source/src/Events
-RUN . /tmp/rid.txt && dotnet restore -r $RID
-
-# Restore Events project dependencies and tools
-WORKDIR /source/src/EventsProcessor
-RUN . /tmp/rid.txt && dotnet restore -r $RID
-
-# Restore Icons project dependencies and tools
-WORKDIR /source/src/Icons
-RUN . /tmp/rid.txt && dotnet restore -r $RID
-
-# Restore Identity project dependencies and tools
-WORKDIR /source/src/Identity
-RUN . /tmp/rid.txt && dotnet restore -r $RID
-
-# Restore Notifications project dependencies and tools
-WORKDIR /source/src/Notifications
-RUN . /tmp/rid.txt && dotnet restore -r $RID
-
-# Restore Sso project dependencies and tools
-WORKDIR /source/bitwarden_license/src/Sso
-RUN . /tmp/rid.txt && dotnet restore -r $RID
-
-# Restore Scim project dependencies and tools
-WORKDIR /source/bitwarden_license/src/Scim
-RUN . /tmp/rid.txt && dotnet restore -r $RID
-
-# Restore Server project dependencies and tools
-WORKDIR /source/util/Server
-RUN . /tmp/rid.txt && dotnet restore -r $RID
-
-# Restore Setup project dependencies and tools
-WORKDIR /source/util/Setup
-RUN . /tmp/rid.txt && dotnet restore -r $RID
-
-# Copy required project files
-WORKDIR /source
-COPY src/Admin/. ./src/Admin/
-COPY src/Api/. ./src/Api/
-COPY src/Billing/. ./src/Billing/
-COPY src/Events/. ./src/Events/
-COPY src/EventsProcessor/. ./src/EventsProcessor/
-COPY src/Icons/. ./src/Icons/
-COPY src/Identity/. ./src/Identity/
-COPY src/Notifications/. ./src/Notifications/
-COPY bitwarden_license/src/Sso/. ./bitwarden_license/src/Sso/
-COPY bitwarden_license/src/Scim/. ./bitwarden_license/src/Scim/
-COPY src/Core/. ./src/Core/
-COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
-COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
-COPY src/SharedWeb/. ./src/SharedWeb/
-COPY util/Migrator/. ./util/Migrator/
-COPY util/MySqlMigrations/. ./util/MySqlMigrations/
-COPY util/PostgresMigrations/. ./util/PostgresMigrations/
-COPY util/Server/. ./util/Server/
-COPY util/Setup/. ./util/Setup/
-COPY util/SqliteMigrations/. ./util/SqliteMigrations/
-COPY util/EfShared/. ./util/EfShared/
-COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
-COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
-COPY .git/. ./.git/
-
-# Build Admin app
-WORKDIR /source/src/Admin
-RUN npm install
-RUN gulp --gulpfile "gulpfile.js" build
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Admin --no-restore --no-self-contained -r $RID
-
-# Build Api app
-WORKDIR /source/src/Api
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Api --no-restore --no-self-contained -r $RID
-
-# Build Billing app
-WORKDIR /source/src/Billing
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Billing --no-restore --no-self-contained -r $RID
-
-# Build Events app
-WORKDIR /source/src/Events
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Events --no-restore --no-self-contained -r $RID
-
-# Build EventsProcessor app
-WORKDIR /source/src/EventsProcessor
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/EventsProcessor --no-restore --no-self-contained -r $RID
-
-# Build Icons app
-WORKDIR /source/src/Icons
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Icons --no-restore --no-self-contained -r $RID
-
-# Build Identity app
-WORKDIR /source/src/Identity
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Identity --no-restore --no-self-contained -r $RID
-
-# Build Notifications app
-WORKDIR /source/src/Notifications
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Notifications --no-restore --no-self-contained -r $RID
-
-# Build Sso app
-WORKDIR /source/bitwarden_license/src/Sso
-RUN npm install
-RUN gulp --gulpfile "gulpfile.js" build
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Sso --no-restore --no-self-contained -r $RID
-
-# Build Scim app
-WORKDIR /source/bitwarden_license/src/Scim
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Scim --no-restore --no-self-contained -r $RID
-
-# Build Server app
-WORKDIR /source/util/Server
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Server --no-restore --no-self-contained -r $RID
-
-# Build Setup app
-WORKDIR /source/util/Setup
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Setup --no-restore --no-self-contained -r $RID
-
-WORKDIR /app
From dd80b2e99f185903f3d0eee89b9eeeb38f708c7f Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 23:35:43 -0500
Subject: [PATCH 050/184] Test
---
.github/workflows/build.yml | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index aad4b44d19..dc7227fe93 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -304,8 +304,18 @@ jobs:
linux/arm/v7,
linux/arm64
push: true
+ outputs: type=tar,dest=${{ matrix.project_name }}.tar
tags: ${{ steps.image-name.outputs.name }}
+ - name: TEST STEP
+ run: |
+ ls -alh
+ mkdir -p TEST
+ mv ${{ matrix.project_name }}.tar TEST/
+ cd TEST
+ tar -xvf admin.tar
+ ls -alh
+
- name: Log out of Docker
run: docker logout
From 285741784a2cda92e6db18f52cb52df15d7777e9 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 23:54:19 -0500
Subject: [PATCH 051/184] Test copying files from Docker images
---
.github/workflows/build.yml | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index dc7227fe93..da7b3a94dc 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -304,17 +304,21 @@ jobs:
linux/arm/v7,
linux/arm64
push: true
- outputs: type=tar,dest=${{ matrix.project_name }}.tar
tags: ${{ steps.image-name.outputs.name }}
- name: TEST STEP
run: |
- ls -alh
- mkdir -p TEST
- mv ${{ matrix.project_name }}.tar TEST/
- cd TEST
- tar -xvf admin.tar
- ls -alh
+ mkdir linux-amd64
+ docker run --rm -ti --platform linux/amd64 --volume $(pwd):/temp ${{ steps.image-name.outputs.name }} cp -r /app /temp/linux-amd64
+ file linux-amd64/app/${{ matrix.project_name }}.dll
+
+ mkdir linux-arm
+ docker run --rm -ti --platform linux/arm --volume $(pwd):/temp ${{ steps.image-name.outputs.name }} cp -r /app /temp/linux-arm
+ file linux-arm/app/${{ matrix.project_name }}.dll
+
+ mkdir linux-arm64
+ docker run --rm -ti --platform linux/arm64 --volume $(pwd):/temp ${{ steps.image-name.outputs.name }} cp -r /app /temp/linux-arm64
+ file linux-arm64/app/${{ matrix.project_name }}.dll
- name: Log out of Docker
run: docker logout
From f50508b0e1f202a2bf8f6f22c84935a5d908af6a Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 15 Nov 2023 23:57:02 -0500
Subject: [PATCH 052/184] Remove interactive flag
---
.github/workflows/build.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index da7b3a94dc..1464b166f7 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -309,15 +309,15 @@ jobs:
- name: TEST STEP
run: |
mkdir linux-amd64
- docker run --rm -ti --platform linux/amd64 --volume $(pwd):/temp ${{ steps.image-name.outputs.name }} cp -r /app /temp/linux-amd64
+ docker run --rm --platform linux/amd64 --volume $(pwd):/temp ${{ steps.image-name.outputs.name }} cp -r /app /temp/linux-amd64
file linux-amd64/app/${{ matrix.project_name }}.dll
mkdir linux-arm
- docker run --rm -ti --platform linux/arm --volume $(pwd):/temp ${{ steps.image-name.outputs.name }} cp -r /app /temp/linux-arm
+ docker run --rm --platform linux/arm --volume $(pwd):/temp ${{ steps.image-name.outputs.name }} cp -r /app /temp/linux-arm
file linux-arm/app/${{ matrix.project_name }}.dll
mkdir linux-arm64
- docker run --rm -ti --platform linux/arm64 --volume $(pwd):/temp ${{ steps.image-name.outputs.name }} cp -r /app /temp/linux-arm64
+ docker run --rm --platform linux/arm64 --volume $(pwd):/temp ${{ steps.image-name.outputs.name }} cp -r /app /temp/linux-arm64
file linux-arm64/app/${{ matrix.project_name }}.dll
- name: Log out of Docker
From 420bcb7c434a2d00d739b7ad982607c1cd5b8c42 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 00:06:00 -0500
Subject: [PATCH 053/184] Test
---
.github/workflows/build.yml | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1464b166f7..ce568cbf3f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -309,16 +309,19 @@ jobs:
- name: TEST STEP
run: |
mkdir linux-amd64
- docker run --rm --platform linux/amd64 --volume $(pwd):/temp ${{ steps.image-name.outputs.name }} cp -r /app /temp/linux-amd64
- file linux-amd64/app/${{ matrix.project_name }}.dll
+ docker run --rm --platform linux/amd64 --volume $(pwd):/temp --entrypoint bash \
+ ${{ steps.image-name.outputs.name }} -c "cp -r ./ /temp/linux-amd64"
+ file linux-amd64/${{ matrix.project_name }}.dll
mkdir linux-arm
- docker run --rm --platform linux/arm --volume $(pwd):/temp ${{ steps.image-name.outputs.name }} cp -r /app /temp/linux-arm
- file linux-arm/app/${{ matrix.project_name }}.dll
+ docker run --rm --platform linux/arm --volume $(pwd):/temp --entrypoint bash \
+ ${{ steps.image-name.outputs.name }} -c "cp -r ./ /temp/linux-arm"
+ file linux-arm/${{ matrix.project_name }}.dll
mkdir linux-arm64
- docker run --rm --platform linux/arm64 --volume $(pwd):/temp ${{ steps.image-name.outputs.name }} cp -r /app /temp/linux-arm64
- file linux-arm64/app/${{ matrix.project_name }}.dll
+ docker run --rm --platform linux/arm64 --volume $(pwd):/temp --entrypoint bash \
+ ${{ steps.image-name.outputs.name }} -c "cp -r ./ /temp/linux-arm64"
+ file linux-arm64/${{ matrix.project_name }}.dll
- name: Log out of Docker
run: docker logout
From aa62e6f10d09b327e77ab7ffa51d269d75a2298b Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 00:09:27 -0500
Subject: [PATCH 054/184] Test
---
.github/workflows/build.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index ce568cbf3f..04fae1e41c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -311,6 +311,8 @@ jobs:
mkdir linux-amd64
docker run --rm --platform linux/amd64 --volume $(pwd):/temp --entrypoint bash \
${{ steps.image-name.outputs.name }} -c "cp -r ./ /temp/linux-amd64"
+ ls -alh
+ ls -alh linux-amd64
file linux-amd64/${{ matrix.project_name }}.dll
mkdir linux-arm
From 4a00dfc3ce8828ebe6bd9302385b88002a1e942e Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 00:16:59 -0500
Subject: [PATCH 055/184] Test
---
.github/workflows/build.yml | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 04fae1e41c..8109fa8d3f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -306,24 +306,28 @@ jobs:
push: true
tags: ${{ steps.image-name.outputs.name }}
- - name: TEST STEP
+ - name: Zip project
+ working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
run: |
- mkdir linux-amd64
- docker run --rm --platform linux/amd64 --volume $(pwd):/temp --entrypoint bash \
- ${{ steps.image-name.outputs.name }} -c "cp -r ./ /temp/linux-amd64"
+ mkdir build
+ docker run --rm --platform linux/amd64 --volume $(pwd)/build:/temp --entrypoint bash \
+ ${{ steps.image-name.outputs.name }} -c "cp -r ./ /temp"
ls -alh
- ls -alh linux-amd64
- file linux-amd64/${{ matrix.project_name }}.dll
+ ls -alh build
- mkdir linux-arm
- docker run --rm --platform linux/arm --volume $(pwd):/temp --entrypoint bash \
- ${{ steps.image-name.outputs.name }} -c "cp -r ./ /temp/linux-arm"
- file linux-arm/${{ matrix.project_name }}.dll
+ cd build
+ zip -r ${{ matrix.project_name }}.zip .
+ mv ${{ matrix.project_name }}.zip ../../../
- mkdir linux-arm64
- docker run --rm --platform linux/arm64 --volume $(pwd):/temp --entrypoint bash \
- ${{ steps.image-name.outputs.name }} -c "cp -r ./ /temp/linux-arm64"
- file linux-arm64/${{ matrix.project_name }}.dll
+ pwd
+ ls -atlh ../../../
+
+ - name: Upload project artifact
+ uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
+ with:
+ name: ${{ matrix.project_name }}.zip
+ path: ${{ matrix.base_path }}/${{ matrix.project_name }}/${{ matrix.project_name }}.zip
+ if-no-files-found: error
- name: Log out of Docker
run: docker logout
From e3c08a28b2e5718f2c54fdf6b7c6a1435c28f66d Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 00:20:05 -0500
Subject: [PATCH 056/184] Test
---
.github/workflows/build.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8109fa8d3f..5f6d6f9d02 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -317,10 +317,10 @@ jobs:
cd build
zip -r ${{ matrix.project_name }}.zip .
- mv ${{ matrix.project_name }}.zip ../../../
+ mv ${{ matrix.project_name }}.zip ../
pwd
- ls -atlh ../../../
+ ls -atlh ../
- name: Upload project artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
From cf6cfeb475848ab4a0db90cc390fac32c8f5c118 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 00:28:46 -0500
Subject: [PATCH 057/184] Test
---
.github/workflows/build.yml | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 5f6d6f9d02..7e0606ad54 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -204,36 +204,49 @@ jobs:
include:
- project_name: Admin
base_path: ./src
+ upload_artifact: true
- project_name: Api
base_path: ./src
+ upload_artifact: true
- project_name: Attachments
base_path: ./util
- project_name: Billing
base_path: ./src
+ upload_artifact: true
- project_name: Events
base_path: ./src
+ upload_artifact: true
- project_name: EventsProcessor
base_path: ./src
+ upload_artifact: true
- project_name: Icons
base_path: ./src
+ upload_artifact: true
- project_name: Identity
base_path: ./src
+ upload_artifact: true
- project_name: MsSql
base_path: ./util
- project_name: MsSqlMigratorUtility
base_path: ./util
+ upload_artifact: true
- project_name: Nginx
base_path: ./util
- project_name: Notifications
base_path: ./src
+ upload_artifact: true
- project_name: Scim
base_path: ./bitwarden_license/src
+ upload_artifact: true
- project_name: Server
base_path: ./util
+ upload_artifact: true
- project_name: Setup
base_path: ./util
+ upload_artifact: true
- project_name: Sso
base_path: ./bitwarden_license/src
+ upload_artifact: true
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
@@ -307,6 +320,7 @@ jobs:
tags: ${{ steps.image-name.outputs.name }}
- name: Zip project
+ if: ${{ matrix.upload_artifact }}
working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
run: |
mkdir build
@@ -323,6 +337,7 @@ jobs:
ls -atlh ../
- name: Upload project artifact
+ if: ${{ matrix.upload_artifact }}
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: ${{ matrix.project_name }}.zip
From 96431771c25357f625f217b3be79015c91196504 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 00:32:19 -0500
Subject: [PATCH 058/184] Update workflow
---
.github/workflows/build.yml | 122 +++---------------------------------
1 file changed, 10 insertions(+), 112 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7e0606ad54..601aa2bf79 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -96,108 +96,12 @@ jobs:
reporter: dotnet-trx
fail-on-error: true
- build-artifacts:
- if: false
- name: Build artifacts
- runs-on: ubuntu-22.04
- needs:
- - testing
- - lint
- strategy:
- fail-fast: false
- matrix:
- include:
- - project_name: Admin
- base_path: ./src
- node: true
- - project_name: Api
- base_path: ./src
- - project_name: Billing
- base_path: ./src
- - project_name: Events
- base_path: ./src
- - project_name: EventsProcessor
- base_path: ./src
- - project_name: Icons
- base_path: ./src
- - project_name: Identity
- base_path: ./src
- - project_name: MsSqlMigratorUtility
- base_path: ./util
- dotnet: true
- - project_name: Notifications
- base_path: ./src
- - project_name: Scim
- base_path: ./bitwarden_license/src
- dotnet: true
- - project_name: Server
- base_path: ./util
- - project_name: Setup
- base_path: ./util
- - project_name: Sso
- base_path: ./bitwarden_license/src
- node: true
- steps:
- - name: Checkout repo
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
-
- - name: Set up dotnet
- uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
-
- - name: Set up Node
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
- with:
- cache: "npm"
- cache-dependency-path: "**/package-lock.json"
- node-version: "16"
-
- - name: Print environment
- run: |
- whoami
- dotnet --info
- node --version
- npm --version
- echo "GitHub ref: $GITHUB_REF"
- echo "GitHub event: $GITHUB_EVENT"
-
- - name: Restore/Clean project
- working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
- run: |
- echo "Restore"
- dotnet restore
- echo "Clean"
- dotnet clean -c "Release" -o obj/build-output/publish
-
- - name: Build node
- if: ${{ matrix.node }}
- working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
- run: |
- npm ci
- npm run build
-
- - name: Publish project
- working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
- run: |
- echo "Publish"
- dotnet publish -c "Release" -o obj/build-output/publish
-
- cd obj/build-output/publish
- zip -r ${{ matrix.project_name }}.zip .
- mv ${{ matrix.project_name }}.zip ../../../
-
- pwd
- ls -atlh ../../../
-
- - name: Upload project artifact
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
- with:
- name: ${{ matrix.project_name }}.zip
- path: ${{ matrix.base_path }}/${{ matrix.project_name }}/${{ matrix.project_name }}.zip
- if-no-files-found: error
-
- build-docker:
- name: Build Docker images
+ build:
+ name: Build artifacts and images
runs-on: ubuntu-22.04
+ # needs:
+ # - lint
+ # - testing
strategy:
fail-fast: false
matrix:
@@ -326,8 +230,6 @@ jobs:
mkdir build
docker run --rm --platform linux/amd64 --volume $(pwd)/build:/temp --entrypoint bash \
${{ steps.image-name.outputs.name }} -c "cp -r ./ /temp"
- ls -alh
- ls -alh build
cd build
zip -r ${{ matrix.project_name }}.zip .
@@ -350,7 +252,7 @@ jobs:
upload:
name: Upload
runs-on: ubuntu-22.04
- needs: build-docker
+ needs: build
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
@@ -534,7 +436,7 @@ jobs:
self-host-build:
name: Trigger self-host build
runs-on: ubuntu-22.04
- needs: build-docker
+ needs: build
steps:
- name: Login to Azure - CI Subscription
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
@@ -571,8 +473,7 @@ jobs:
- cloc
- lint
- testing
- - build-artifacts
- - build-docker
+ - build
- upload
- build-mssqlmigratorutility
- self-host-build
@@ -586,8 +487,7 @@ jobs:
CLOC_STATUS: ${{ needs.cloc.result }}
LINT_STATUS: ${{ needs.lint.result }}
TESTING_STATUS: ${{ needs.testing.result }}
- BUILD_ARTIFACTS_STATUS: ${{ needs.build-artifacts.result }}
- BUILD_DOCKER_STATUS: ${{ needs.build-docker.result }}
+ BUILD_STATUS: ${{ needs.build.result }}
UPLOAD_STATUS: ${{ needs.upload.result }}
BUILD_MSSQLMIGRATORUTILITY_STATUS: ${{ needs.build-mssqlmigratorutility.result }}
TRIGGER_SELF_HOST_BUILD_STATUS: ${{ needs.self-host-build.result }}
@@ -598,9 +498,7 @@ jobs:
exit 1
elif [ "$TESTING_STATUS" = "failure" ]; then
exit 1
- elif [ "$BUILD_ARTIFACTS_STATUS" = "failure" ]; then
- exit 1
- elif [ "$BUILD_DOCKER_STATUS" = "failure" ]; then
+ elif [ "$BUILD_STATUS" = "failure" ]; then
exit 1
elif [ "$UPLOAD_STATUS" = "failure" ]; then
exit 1
From ff72a905748baf448042f11284fc62fc0d1bae4b Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 09:17:10 -0500
Subject: [PATCH 059/184] Add platforms
---
.github/workflows/build.yml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 601aa2bf79..fd1f467eac 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -217,9 +217,12 @@ jobs:
context: .
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
platforms: |
+ linux/386,
linux/amd64,
+ linux/arm/v6,
linux/arm/v7,
- linux/arm64
+ linux/arm64,
+ linux/riscv64
push: true
tags: ${{ steps.image-name.outputs.name }}
From 4b695f158b0c094b84d537cfba75d01087856a63 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 09:20:51 -0500
Subject: [PATCH 060/184] Remove platform
---
.github/workflows/build.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index fd1f467eac..16cd3d2d8c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -221,8 +221,7 @@ jobs:
linux/amd64,
linux/arm/v6,
linux/arm/v7,
- linux/arm64,
- linux/riscv64
+ linux/arm64
push: true
tags: ${{ steps.image-name.outputs.name }}
From 7bed9d18f2e8b94949eecf5f628631b8a1f7e711 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 09:24:31 -0500
Subject: [PATCH 061/184] Remove platform
---
.github/workflows/build.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 16cd3d2d8c..b099cc002d 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -217,7 +217,6 @@ jobs:
context: .
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
platforms: |
- linux/386,
linux/amd64,
linux/arm/v6,
linux/arm/v7,
From 5aa2b214154f67f9486eca42361668c8282e5532 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 09:30:29 -0500
Subject: [PATCH 062/184] Put platforms back to normal
---
.github/workflows/build.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index b099cc002d..601aa2bf79 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -218,7 +218,6 @@ jobs:
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
platforms: |
linux/amd64,
- linux/arm/v6,
linux/arm/v7,
linux/arm64
push: true
From 1b2e7a3ed7a47c1c55636f371386aa82a57c8223 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 09:40:51 -0500
Subject: [PATCH 063/184] Fix MsSqlMigratorUtility
---
util/MsSqlMigratorUtility/Dockerfile | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/util/MsSqlMigratorUtility/Dockerfile b/util/MsSqlMigratorUtility/Dockerfile
index 815a53011d..ee4b6d2712 100644
--- a/util/MsSqlMigratorUtility/Dockerfile
+++ b/util/MsSqlMigratorUtility/Dockerfile
@@ -2,23 +2,41 @@
# Build stage #
###############################################
-FROM mcr.microsoft.com/dotnet/sdk:6.0 AS bitwarden-build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS bitwarden-build
+
+# Docker buildx supplies the value for this arg
+ARG TARGETPLATFORM
+
+# Determine proper runtime value for .NET
+# We put the value in a file to be read by later layers.
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+ RID=linux-x64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
+ RID=linux-arm64 ; \
+ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
+ RID=linux-arm ; \
+ fi \
+ && echo "RID=$RID" > /tmp/rid.txt
# Copy csproj files as distinct layers
WORKDIR /source
+COPY src/Core/*.csproj ./src/Core/
+COPY util/Migrator/*.csproj ./util/Migrator/
COPY util/MsSqlMigratorUtility/*.csproj ./util/MsSqlMigratorUtility/
# Restore MsSqlMigratorUtility project dependencies and tools
WORKDIR /source/util/MsSqlMigratorUtility
-RUN dotnet restore
+RUN . /tmp/rid.txt && dotnet restore -r $RID
# Copy required project files
WORKDIR /source
+COPY src/Core/. ./src/Core/
+COPY util/Migrator/. ./util/Migrator/
COPY util/MsSqlMigratorUtility/. ./util/MsSqlMigratorUtility/
-# Build Setup app
+# Build MsSqlMigratorUtility app
WORKDIR /source/util/MsSqlMigratorUtility
-RUN dotnet publish -c release -o /app/MsSqlMigratorUtility --no-restore --no-self-contained
+RUN . /tmp/rid.txt && dotnet publish -c release -o /app/MsSqlMigratorUtility --no-restore --no-self-contained -r $RID
WORKDIR /app
@@ -27,6 +45,7 @@ WORKDIR /app
###############################################
FROM mcr.microsoft.com/dotnet/aspnet:6.0
+ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
# Copy app from the build stage
From 646c5c72103e880ceb381e802feb92546e9657ee Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 09:48:59 -0500
Subject: [PATCH 064/184] Add proper files to Dockerfile
---
util/MsSqlMigratorUtility/Dockerfile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/util/MsSqlMigratorUtility/Dockerfile b/util/MsSqlMigratorUtility/Dockerfile
index ee4b6d2712..69342ccfd2 100644
--- a/util/MsSqlMigratorUtility/Dockerfile
+++ b/util/MsSqlMigratorUtility/Dockerfile
@@ -23,6 +23,7 @@ WORKDIR /source
COPY src/Core/*.csproj ./src/Core/
COPY util/Migrator/*.csproj ./util/Migrator/
COPY util/MsSqlMigratorUtility/*.csproj ./util/MsSqlMigratorUtility/
+COPY Directory.Build.props .
# Restore MsSqlMigratorUtility project dependencies and tools
WORKDIR /source/util/MsSqlMigratorUtility
@@ -33,6 +34,7 @@ WORKDIR /source
COPY src/Core/. ./src/Core/
COPY util/Migrator/. ./util/Migrator/
COPY util/MsSqlMigratorUtility/. ./util/MsSqlMigratorUtility/
+COPY .git/. ./.git/
# Build MsSqlMigratorUtility app
WORKDIR /source/util/MsSqlMigratorUtility
From 4ed7907f33604dee33111b7b75ebe0a1e875f026 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 10:44:37 -0500
Subject: [PATCH 065/184] Re-enable jobs
---
.github/workflows/build.yml | 29 ++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 601aa2bf79..7cbce5e6cf 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -15,12 +15,11 @@ env:
jobs:
cloc:
- if: false
name: CLOC
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install cloc
run: |
@@ -31,12 +30,11 @@ jobs:
run: cloc --include-lang C#,SQL,Razor,"Bourne Shell",PowerShell,HTML,CSS,Sass,JavaScript,TypeScript --vcs git
lint:
- if: false
name: Lint
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up dotnet
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
@@ -45,14 +43,13 @@ jobs:
run: dotnet format --verify-no-changes
testing:
- if: false
name: Testing
runs-on: ubuntu-22.04
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps:
- name: Checkout repo
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up dotnet
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
@@ -99,9 +96,9 @@ jobs:
build:
name: Build artifacts and images
runs-on: ubuntu-22.04
- # needs:
- # - lint
- # - testing
+ needs:
+ - lint
+ - testing
strategy:
fail-fast: false
matrix:
@@ -212,8 +209,6 @@ jobs:
- name: Build Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
- build-args: |
- BUILD_TAG=${{ steps.tag.outputs.image_tag }}
context: .
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
platforms: |
@@ -249,8 +244,8 @@ jobs:
- name: Log out of Docker
run: docker logout
- upload:
- name: Upload
+ build-stub-swagger:
+ name: Build Docker-Stub/Swagger
runs-on: ubuntu-22.04
needs: build
steps:
@@ -394,7 +389,7 @@ jobs:
- win-x64
steps:
- name: Checkout repo
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up dotnet
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
@@ -474,7 +469,7 @@ jobs:
- lint
- testing
- build
- - upload
+ - build-stub-swagger
- build-mssqlmigratorutility
- self-host-build
steps:
@@ -488,7 +483,7 @@ jobs:
LINT_STATUS: ${{ needs.lint.result }}
TESTING_STATUS: ${{ needs.testing.result }}
BUILD_STATUS: ${{ needs.build.result }}
- UPLOAD_STATUS: ${{ needs.upload.result }}
+ BUILD_STUB_SWAGGER_STATUS: ${{ needs.build-stub-swagger.result }}
BUILD_MSSQLMIGRATORUTILITY_STATUS: ${{ needs.build-mssqlmigratorutility.result }}
TRIGGER_SELF_HOST_BUILD_STATUS: ${{ needs.self-host-build.result }}
run: |
@@ -500,7 +495,7 @@ jobs:
exit 1
elif [ "$BUILD_STATUS" = "failure" ]; then
exit 1
- elif [ "$UPLOAD_STATUS" = "failure" ]; then
+ elif [ "$BUILD_STUB_SWAGGER_STATUS" = "failure" ]; then
exit 1
elif [ "$BUILD_MSSQLMIGRATORUTILITY_STATUS" = "failure" ]; then
exit 1
From 42638c4fc04c66fa533d0e2b73bd4674122c9cad Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 11:06:14 -0500
Subject: [PATCH 066/184] Try larger runner
---
.github/workflows/build.yml | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7cbce5e6cf..42ff8d01ad 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -44,7 +44,7 @@ jobs:
testing:
name: Testing
- runs-on: ubuntu-22.04
+ runs-on: ubuntu-latest-m
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps:
@@ -95,10 +95,8 @@ jobs:
build:
name: Build artifacts and images
- runs-on: ubuntu-22.04
- needs:
- - lint
- - testing
+ runs-on: ubuntu-latest-m
+ needs: testing
strategy:
fail-fast: false
matrix:
@@ -247,7 +245,7 @@ jobs:
build-stub-swagger:
name: Build Docker-Stub/Swagger
runs-on: ubuntu-22.04
- needs: build
+ needs: testing
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
From 8ddc7711a1971edd578bce604701a4924fdb46d4 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 11:08:00 -0500
Subject: [PATCH 067/184] Change back to regular runners
---
.github/workflows/build.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 42ff8d01ad..71865fa917 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -44,7 +44,7 @@ jobs:
testing:
name: Testing
- runs-on: ubuntu-latest-m
+ runs-on: ubuntu-22.04
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps:
@@ -95,7 +95,7 @@ jobs:
build:
name: Build artifacts and images
- runs-on: ubuntu-latest-m
+ runs-on: ubuntu-22.04
needs: testing
strategy:
fail-fast: false
From 7fc0c6805cc16ee66a155762c4c7e901d3551969 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 11:14:20 -0500
Subject: [PATCH 068/184] Enable locked mode for NuGet restore
---
.github/workflows/build.yml | 4 ++--
bitwarden_license/src/Scim/Dockerfile | 2 +-
src/Admin/Dockerfile | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 71865fa917..e477d57ce4 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -348,7 +348,7 @@ jobs:
run: |
cd ./src/Api
echo "Restore"
- dotnet restore
+ dotnet restore --locked-mode
echo "Clean"
dotnet clean -c "Release" -o obj/build-output/publish
echo "Publish"
@@ -402,7 +402,7 @@ jobs:
- name: Restore project
run: |
echo "Restore"
- dotnet restore
+ dotnet restore --locked-mode
- name: Publish project
run: |
diff --git a/bitwarden_license/src/Scim/Dockerfile b/bitwarden_license/src/Scim/Dockerfile
index 0c97fdcf49..abfbd22821 100644
--- a/bitwarden_license/src/Scim/Dockerfile
+++ b/bitwarden_license/src/Scim/Dockerfile
@@ -28,7 +28,7 @@ COPY Directory.Build.props .
# Restore Scim project dependencies and tools
WORKDIR /source/bitwarden_license/src/Scim
-RUN . /tmp/rid.txt && dotnet restore -r $RID
+RUN . /tmp/rid.txt && dotnet restore --locked-mode -r $RID
# Copy required project files
WORKDIR /source
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 20930d774e..1d046e921e 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -54,7 +54,7 @@ COPY Directory.Build.props .
# Restore Admin project dependencies and tools
WORKDIR /source/src/Admin
-RUN . /tmp/rid.txt && dotnet restore -r $RID
+RUN . /tmp/rid.txt && dotnet restore --locked-mode -r $RID
# Copy required project files
WORKDIR /source
From 3af9fe262dbd351f058eb91be70fa3a3ca54e7f1 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 11:40:17 -0500
Subject: [PATCH 069/184] Test Docker cache
---
.github/workflows/build.yml | 2 ++
bitwarden_license/src/Scim/Dockerfile | 2 +-
src/Admin/Dockerfile | 2 +-
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e477d57ce4..8d73e06379 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -207,6 +207,8 @@ jobs:
- name: Build Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
+ cache-from: type=registry,ref=${{ steps.image-name.outputs.name }}
+ cache-to: type=inline
context: .
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
platforms: |
diff --git a/bitwarden_license/src/Scim/Dockerfile b/bitwarden_license/src/Scim/Dockerfile
index abfbd22821..0c97fdcf49 100644
--- a/bitwarden_license/src/Scim/Dockerfile
+++ b/bitwarden_license/src/Scim/Dockerfile
@@ -28,7 +28,7 @@ COPY Directory.Build.props .
# Restore Scim project dependencies and tools
WORKDIR /source/bitwarden_license/src/Scim
-RUN . /tmp/rid.txt && dotnet restore --locked-mode -r $RID
+RUN . /tmp/rid.txt && dotnet restore -r $RID
# Copy required project files
WORKDIR /source
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 1d046e921e..20930d774e 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -54,7 +54,7 @@ COPY Directory.Build.props .
# Restore Admin project dependencies and tools
WORKDIR /source/src/Admin
-RUN . /tmp/rid.txt && dotnet restore --locked-mode -r $RID
+RUN . /tmp/rid.txt && dotnet restore -r $RID
# Copy required project files
WORKDIR /source
From 0366f86a56b13b85d96da31f46ddf256af85b2b5 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 11:42:41 -0500
Subject: [PATCH 070/184] Update needs for MsSqlMigratorUtility job
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8d73e06379..9748cf5fdc 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -375,7 +375,7 @@ jobs:
build-mssqlmigratorutility:
name: Build MsSqlMigratorUtility
runs-on: ubuntu-22.04
- needs: lint
+ needs: testing
defaults:
run:
shell: bash
From 0ecadedda9b3f1769e26e8a778e3d2c49263ab16 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 11:44:45 -0500
Subject: [PATCH 071/184] Change needs for self-host-build
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 9748cf5fdc..44360c3dfd 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -431,7 +431,7 @@ jobs:
self-host-build:
name: Trigger self-host build
runs-on: ubuntu-22.04
- needs: build
+ needs: testing
steps:
- name: Login to Azure - CI Subscription
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
From 75b8294a5c996a45c74bff5f1bf515a2cade1f99 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 12:11:43 -0500
Subject: [PATCH 072/184] Add buildcache
---
.github/workflows/build.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 44360c3dfd..70c88980ed 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -207,8 +207,8 @@ jobs:
- name: Build Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
- cache-from: type=registry,ref=${{ steps.image-name.outputs.name }}
- cache-to: type=inline
+ cache-from: type=registry,ref=${{ steps.image-name.outputs.name }}-buildcache
+ cache-to: type=registry,ref=${{ steps.image-name.outputs.name }}-buildcache,mode=max
context: .
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
platforms: |
From f5dc7f4d530b046eca87362360177583fb1a598e Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 14:21:08 -0500
Subject: [PATCH 073/184] Modify cache
---
.github/workflows/build.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 70c88980ed..44360c3dfd 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -207,8 +207,8 @@ jobs:
- name: Build Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
- cache-from: type=registry,ref=${{ steps.image-name.outputs.name }}-buildcache
- cache-to: type=registry,ref=${{ steps.image-name.outputs.name }}-buildcache,mode=max
+ cache-from: type=registry,ref=${{ steps.image-name.outputs.name }}
+ cache-to: type=inline
context: .
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
platforms: |
From ecf692e9b4c59ed1177f1f3133a1a6bc072b3f2e Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 14:58:05 -0500
Subject: [PATCH 074/184] Update workflow
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 44360c3dfd..bd4ce8c7dc 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -224,7 +224,7 @@ jobs:
run: |
mkdir build
docker run --rm --platform linux/amd64 --volume $(pwd)/build:/temp --entrypoint bash \
- ${{ steps.image-name.outputs.name }} -c "cp -r ./ /temp"
+ ${{ steps.image-name.outputs.name }} -c "cp -r ./ /temp"
cd build
zip -r ${{ matrix.project_name }}.zip .
From 70e9124b6b63050fb3ce37ac8ff69c8fbd78c3e4 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 15:00:47 -0500
Subject: [PATCH 075/184] Remove Server project Dockerfile
---
.github/workflows/build.yml | 3 ---
util/Server/.dockerignore | 3 ---
util/Server/Dockerfile | 49 -------------------------------------
3 files changed, 55 deletions(-)
delete mode 100644 util/Server/.dockerignore
delete mode 100644 util/Server/Dockerfile
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index bd4ce8c7dc..87655cdb58 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -137,9 +137,6 @@ jobs:
- project_name: Scim
base_path: ./bitwarden_license/src
upload_artifact: true
- - project_name: Server
- base_path: ./util
- upload_artifact: true
- project_name: Setup
base_path: ./util
upload_artifact: true
diff --git a/util/Server/.dockerignore b/util/Server/.dockerignore
deleted file mode 100644
index 546b9afbef..0000000000
--- a/util/Server/.dockerignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*
-!obj/build-output/publish/*
-!obj/Docker/empty/
diff --git a/util/Server/Dockerfile b/util/Server/Dockerfile
deleted file mode 100644
index 8b78751ca1..0000000000
--- a/util/Server/Dockerfile
+++ /dev/null
@@ -1,49 +0,0 @@
-###############################################
-# Build stage #
-###############################################
-FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
-
-# Docker buildx supplies the value for this arg
-ARG TARGETPLATFORM
-
-# Determine proper runtime value for .NET
-# We put the value in a file to be read by later layers.
-RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
- RID=linux-x64 ; \
- elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
- RID=linux-arm64 ; \
- elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
- RID=linux-arm ; \
- fi \
- && echo "RID=$RID" > /tmp/rid.txt
-
-# Copy csproj files as distinct layers
-WORKDIR /source
-COPY util/Server/*.csproj ./util/Server/
-COPY Directory.Build.props .
-
-# Restore Server project dependencies and tools
-WORKDIR /source/util/Server
-RUN . /tmp/rid.txt && dotnet restore -r $RID
-
-# Copy required project files
-WORKDIR /source
-COPY util/Server/. ./util/Server/
-COPY .git/. ./.git/
-
-# Build Server app
-WORKDIR /source/util/Server
-RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Server --no-restore --no-self-contained -r $RID
-
-WORKDIR /app
-
-###############################################
-# App stage #
-###############################################
-FROM mcr.microsoft.com/dotnet/aspnet:6.0
-
-LABEL com.bitwarden.product="bitwarden"
-
-# Copy app from the build stage
-WORKDIR /bitwarden_server
-COPY --from=build /app/Server ./
\ No newline at end of file
From 10c8790f25f6c440fbe56405580a05debb285d36 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 16 Nov 2023 15:52:46 -0500
Subject: [PATCH 076/184] Update comments in Dockerfiles
---
bitwarden_license/src/Scim/.dockerignore | 4 ----
bitwarden_license/src/Scim/Dockerfile | 4 ++--
bitwarden_license/src/Sso/Dockerfile | 11 ++++-------
src/Admin/.dockerignore | 4 ----
src/Admin/Dockerfile | 11 ++++-------
src/Api/.dockerignore | 4 ----
src/Api/Dockerfile | 4 ++--
src/Billing/.dockerignore | 4 ----
src/Billing/Dockerfile | 4 ++--
src/Events/.dockerignore | 4 ----
src/Events/Dockerfile | 4 ++--
src/EventsProcessor/Dockerfile | 4 ++--
src/Icons/.dockerignore | 4 ----
src/Icons/Dockerfile | 4 ++--
src/Identity/.dockerignore | 4 ----
src/Identity/Dockerfile | 4 ++--
src/Notifications/.dockerignore | 4 ----
src/Notifications/Dockerfile | 4 ++--
util/Attachments/.dockerignore | 2 --
util/Attachments/Dockerfile | 4 ++--
util/MsSqlMigratorUtility/.dockerignore | 3 ---
util/MsSqlMigratorUtility/Dockerfile | 4 ++--
util/Setup/.dockerignore | 4 ----
util/Setup/Dockerfile | 4 ++--
24 files changed, 30 insertions(+), 77 deletions(-)
delete mode 100644 bitwarden_license/src/Scim/.dockerignore
delete mode 100644 src/Admin/.dockerignore
delete mode 100644 src/Api/.dockerignore
delete mode 100644 src/Billing/.dockerignore
delete mode 100644 src/Events/.dockerignore
delete mode 100644 src/Icons/.dockerignore
delete mode 100644 src/Identity/.dockerignore
delete mode 100644 src/Notifications/.dockerignore
delete mode 100644 util/Attachments/.dockerignore
delete mode 100644 util/MsSqlMigratorUtility/.dockerignore
delete mode 100644 util/Setup/.dockerignore
diff --git a/bitwarden_license/src/Scim/.dockerignore b/bitwarden_license/src/Scim/.dockerignore
deleted file mode 100644
index fc12f25146..0000000000
--- a/bitwarden_license/src/Scim/.dockerignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*
-!obj/build-output/publish/*
-!obj/Docker/empty/
-!entrypoint.sh
diff --git a/bitwarden_license/src/Scim/Dockerfile b/bitwarden_license/src/Scim/Dockerfile
index 0c97fdcf49..a6823a46a3 100644
--- a/bitwarden_license/src/Scim/Dockerfile
+++ b/bitwarden_license/src/Scim/Dockerfile
@@ -26,7 +26,7 @@ COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFram
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
-# Restore Scim project dependencies and tools
+# Restore project dependencies and tools
WORKDIR /source/bitwarden_license/src/Scim
RUN . /tmp/rid.txt && dotnet restore -r $RID
@@ -39,7 +39,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build Scim app
+# Build app
WORKDIR /source/bitwarden_license/src/Scim
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Scim --no-restore --no-self-contained -r $RID
diff --git a/bitwarden_license/src/Sso/Dockerfile b/bitwarden_license/src/Sso/Dockerfile
index 784647dee2..e53fdeb1af 100644
--- a/bitwarden_license/src/Sso/Dockerfile
+++ b/bitwarden_license/src/Sso/Dockerfile
@@ -34,9 +34,6 @@ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | b
ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
-# Install gulp
-RUN npm install -g gulp
-
# Copy csproj files as distinct layers
WORKDIR /source
COPY bitwarden_license/src/Sso/*.csproj ./bitwarden_license/src/Sso/
@@ -46,7 +43,7 @@ COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFram
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
-# Restore Sso project dependencies and tools
+# Restore project dependencies and tools
WORKDIR /source/bitwarden_license/src/Sso
RUN . /tmp/rid.txt && dotnet restore -r $RID
@@ -59,10 +56,10 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build Sso app
+# Build app
WORKDIR /source/bitwarden_license/src/Sso
-RUN npm install
-RUN gulp --gulpfile "gulpfile.js" build
+RUN npm ci
+RUN npm run build
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Sso --no-restore --no-self-contained -r $RID
WORKDIR /app
diff --git a/src/Admin/.dockerignore b/src/Admin/.dockerignore
deleted file mode 100644
index fc12f25146..0000000000
--- a/src/Admin/.dockerignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*
-!obj/build-output/publish/*
-!obj/Docker/empty/
-!entrypoint.sh
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 20930d774e..f9eeb172c9 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -34,9 +34,6 @@ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | b
ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
-# Install gulp
-RUN npm install -g gulp
-
# Copy csproj files as distinct layers
WORKDIR /source
COPY src/Admin/*.csproj ./src/Admin/
@@ -52,7 +49,7 @@ COPY bitwarden_license/src/Commercial.Core/*.csproj ./bitwarden_license/src/Comm
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/*.csproj ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
COPY Directory.Build.props .
-# Restore Admin project dependencies and tools
+# Restore project dependencies and tools
WORKDIR /source/src/Admin
RUN . /tmp/rid.txt && dotnet restore -r $RID
@@ -72,10 +69,10 @@ COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
COPY .git/. ./.git/
-# Build Admin app
+# Build app
WORKDIR /source/src/Admin
-RUN npm install
-RUN gulp --gulpfile "gulpfile.js" build
+RUN npm ci
+RUN npm run build
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Admin --no-restore --no-self-contained -r $RID
WORKDIR /app
diff --git a/src/Api/.dockerignore b/src/Api/.dockerignore
deleted file mode 100644
index fc12f25146..0000000000
--- a/src/Api/.dockerignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*
-!obj/build-output/publish/*
-!obj/Docker/empty/
-!entrypoint.sh
diff --git a/src/Api/Dockerfile b/src/Api/Dockerfile
index 0f6e70ff86..728d1accd2 100644
--- a/src/Api/Dockerfile
+++ b/src/Api/Dockerfile
@@ -28,7 +28,7 @@ COPY bitwarden_license/src/Commercial.Core/*.csproj ./bitwarden_license/src/Comm
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/*.csproj ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
COPY Directory.Build.props .
-# Restore Api project dependencies and tools
+# Restore project dependencies and tools
WORKDIR /source/src/Api
RUN . /tmp/rid.txt && dotnet restore -r $RID
@@ -43,7 +43,7 @@ COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
COPY .git/. ./.git/
-# Build Api app
+# Build app
WORKDIR /source/src/Api
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Api --no-restore --no-self-contained -r $RID
diff --git a/src/Billing/.dockerignore b/src/Billing/.dockerignore
deleted file mode 100644
index fc12f25146..0000000000
--- a/src/Billing/.dockerignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*
-!obj/build-output/publish/*
-!obj/Docker/empty/
-!entrypoint.sh
diff --git a/src/Billing/Dockerfile b/src/Billing/Dockerfile
index 58258f5730..9c17890bd8 100644
--- a/src/Billing/Dockerfile
+++ b/src/Billing/Dockerfile
@@ -26,7 +26,7 @@ COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFram
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
-# Restore Billing project dependencies and tools
+# Restore project dependencies and tools
WORKDIR /source/src/Billing
RUN . /tmp/rid.txt && dotnet restore -r $RID
@@ -39,7 +39,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build Billing app
+# Build app
WORKDIR /source/src/Billing
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Billing --no-restore --no-self-contained -r $RID
diff --git a/src/Events/.dockerignore b/src/Events/.dockerignore
deleted file mode 100644
index fc12f25146..0000000000
--- a/src/Events/.dockerignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*
-!obj/build-output/publish/*
-!obj/Docker/empty/
-!entrypoint.sh
diff --git a/src/Events/Dockerfile b/src/Events/Dockerfile
index 2833c860f9..88a0b06530 100644
--- a/src/Events/Dockerfile
+++ b/src/Events/Dockerfile
@@ -26,7 +26,7 @@ COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFram
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
-# Restore Events project dependencies and tools
+# Restore project dependencies and tools
WORKDIR /source/src/Events
RUN . /tmp/rid.txt && dotnet restore -r $RID
@@ -39,7 +39,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build Events app
+# Build app
WORKDIR /source/src/Events
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Events --no-restore --no-self-contained -r $RID
diff --git a/src/EventsProcessor/Dockerfile b/src/EventsProcessor/Dockerfile
index 7b67dffb7f..28e1d72357 100644
--- a/src/EventsProcessor/Dockerfile
+++ b/src/EventsProcessor/Dockerfile
@@ -26,7 +26,7 @@ COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFram
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
-# Restore EventsProcessor project dependencies and tools
+# Restore project dependencies and tools
WORKDIR /source/src/EventsProcessor
RUN . /tmp/rid.txt && dotnet restore -r $RID
@@ -39,7 +39,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build EventsProcessor app
+# Build app
WORKDIR /source/src/EventsProcessor
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/EventsProcessor --no-restore --no-self-contained -r $RID
diff --git a/src/Icons/.dockerignore b/src/Icons/.dockerignore
deleted file mode 100644
index fc12f25146..0000000000
--- a/src/Icons/.dockerignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*
-!obj/build-output/publish/*
-!obj/Docker/empty/
-!entrypoint.sh
diff --git a/src/Icons/Dockerfile b/src/Icons/Dockerfile
index 384f75410d..f4780fe779 100644
--- a/src/Icons/Dockerfile
+++ b/src/Icons/Dockerfile
@@ -26,7 +26,7 @@ COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFram
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
-# Restore Icons project dependencies and tools
+# Restore project dependencies and tools
WORKDIR /source/src/Icons
RUN . /tmp/rid.txt && dotnet restore -r $RID
@@ -39,7 +39,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build Icons app
+# Build app
WORKDIR /source/src/Icons
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Icons --no-restore --no-self-contained -r $RID
diff --git a/src/Identity/.dockerignore b/src/Identity/.dockerignore
deleted file mode 100644
index fc12f25146..0000000000
--- a/src/Identity/.dockerignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*
-!obj/build-output/publish/*
-!obj/Docker/empty/
-!entrypoint.sh
diff --git a/src/Identity/Dockerfile b/src/Identity/Dockerfile
index cbcc32413e..cc2bc1618f 100644
--- a/src/Identity/Dockerfile
+++ b/src/Identity/Dockerfile
@@ -26,7 +26,7 @@ COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFram
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
-# Restore Identity project dependencies and tools
+# Restore project dependencies and tools
WORKDIR /source/src/Identity
RUN . /tmp/rid.txt && dotnet restore -r $RID
@@ -39,7 +39,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build Identity app
+# Build app
WORKDIR /source/src/Identity
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Identity --no-restore --no-self-contained -r $RID
diff --git a/src/Notifications/.dockerignore b/src/Notifications/.dockerignore
deleted file mode 100644
index fc12f25146..0000000000
--- a/src/Notifications/.dockerignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*
-!obj/build-output/publish/*
-!obj/Docker/empty/
-!entrypoint.sh
diff --git a/src/Notifications/Dockerfile b/src/Notifications/Dockerfile
index b257fcb367..a13d3b4fd9 100644
--- a/src/Notifications/Dockerfile
+++ b/src/Notifications/Dockerfile
@@ -26,7 +26,7 @@ COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFram
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
-# Restore Notifications project dependencies and tools
+# Restore project dependencies and tools
WORKDIR /source/src/Notifications
RUN . /tmp/rid.txt && dotnet restore -r $RID
@@ -39,7 +39,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build Notifications app
+# Build app
WORKDIR /source/src/Notifications
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Notifications --no-restore --no-self-contained -r $RID
diff --git a/util/Attachments/.dockerignore b/util/Attachments/.dockerignore
deleted file mode 100644
index 864179fda5..0000000000
--- a/util/Attachments/.dockerignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*
-!entrypoint.sh
diff --git a/util/Attachments/Dockerfile b/util/Attachments/Dockerfile
index 4270972f71..407792b1af 100644
--- a/util/Attachments/Dockerfile
+++ b/util/Attachments/Dockerfile
@@ -22,7 +22,7 @@ WORKDIR /source
COPY util/Server/*.csproj ./util/Server/
COPY Directory.Build.props .
-# Restore Server project dependencies and tools
+# Restore project dependencies and tools
WORKDIR /source/util/Server
RUN . /tmp/rid.txt && dotnet restore -r $RID
@@ -31,7 +31,7 @@ WORKDIR /source
COPY util/Server/. ./util/Server/
COPY .git/. ./.git/
-# Build Server app
+# Build app
WORKDIR /source/util/Server
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Server --no-restore --no-self-contained -r $RID
diff --git a/util/MsSqlMigratorUtility/.dockerignore b/util/MsSqlMigratorUtility/.dockerignore
deleted file mode 100644
index 546b9afbef..0000000000
--- a/util/MsSqlMigratorUtility/.dockerignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*
-!obj/build-output/publish/*
-!obj/Docker/empty/
diff --git a/util/MsSqlMigratorUtility/Dockerfile b/util/MsSqlMigratorUtility/Dockerfile
index 69342ccfd2..f7c3917fc3 100644
--- a/util/MsSqlMigratorUtility/Dockerfile
+++ b/util/MsSqlMigratorUtility/Dockerfile
@@ -25,7 +25,7 @@ COPY util/Migrator/*.csproj ./util/Migrator/
COPY util/MsSqlMigratorUtility/*.csproj ./util/MsSqlMigratorUtility/
COPY Directory.Build.props .
-# Restore MsSqlMigratorUtility project dependencies and tools
+# Restore project dependencies and tools
WORKDIR /source/util/MsSqlMigratorUtility
RUN . /tmp/rid.txt && dotnet restore -r $RID
@@ -36,7 +36,7 @@ COPY util/Migrator/. ./util/Migrator/
COPY util/MsSqlMigratorUtility/. ./util/MsSqlMigratorUtility/
COPY .git/. ./.git/
-# Build MsSqlMigratorUtility app
+# Build app
WORKDIR /source/util/MsSqlMigratorUtility
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/MsSqlMigratorUtility --no-restore --no-self-contained -r $RID
diff --git a/util/Setup/.dockerignore b/util/Setup/.dockerignore
deleted file mode 100644
index fc12f25146..0000000000
--- a/util/Setup/.dockerignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*
-!obj/build-output/publish/*
-!obj/Docker/empty/
-!entrypoint.sh
diff --git a/util/Setup/Dockerfile b/util/Setup/Dockerfile
index dce42a14bb..0b91995f7b 100644
--- a/util/Setup/Dockerfile
+++ b/util/Setup/Dockerfile
@@ -24,7 +24,7 @@ COPY util/Migrator/*.csproj ./util/Migrator/
COPY util/Setup/*.csproj ./util/Setup/
COPY Directory.Build.props .
-# Restore Setup project dependencies and tools
+# Restore project dependencies and tools
WORKDIR /source/util/Setup
RUN . /tmp/rid.txt && dotnet restore -r $RID
@@ -35,7 +35,7 @@ COPY util/Migrator/. ./util/Migrator/
COPY util/Setup/. ./util/Setup/
COPY .git/. ./.git/
-# Build Setup app
+# Build app
WORKDIR /source/util/Setup
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Setup --no-restore --no-self-contained -r $RID
From eb5830ef11d5cd470c526eabb46371ff8a4c19a4 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Mon, 20 Nov 2023 16:36:33 -0500
Subject: [PATCH 077/184] Update comments in Dockerfiles
---
bitwarden_license/src/Scim/Dockerfile | 2 +-
bitwarden_license/src/Sso/Dockerfile | 2 +-
src/Admin/Dockerfile | 17 +++++++++--------
src/Api/Dockerfile | 2 +-
src/Billing/Dockerfile | 2 +-
src/Events/Dockerfile | 2 +-
src/EventsProcessor/Dockerfile | 2 +-
src/Icons/Dockerfile | 2 +-
src/Identity/Dockerfile | 2 +-
src/Notifications/Dockerfile | 2 +-
util/Attachments/Dockerfile | 2 +-
util/MsSqlMigratorUtility/Dockerfile | 2 +-
util/Setup/Dockerfile | 2 +-
13 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/bitwarden_license/src/Scim/Dockerfile b/bitwarden_license/src/Scim/Dockerfile
index a6823a46a3..51ed4458e2 100644
--- a/bitwarden_license/src/Scim/Dockerfile
+++ b/bitwarden_license/src/Scim/Dockerfile
@@ -39,7 +39,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build app
+# Build project
WORKDIR /source/bitwarden_license/src/Scim
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Scim --no-restore --no-self-contained -r $RID
diff --git a/bitwarden_license/src/Sso/Dockerfile b/bitwarden_license/src/Sso/Dockerfile
index e53fdeb1af..2541bc8878 100644
--- a/bitwarden_license/src/Sso/Dockerfile
+++ b/bitwarden_license/src/Sso/Dockerfile
@@ -56,7 +56,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build app
+# Build project
WORKDIR /source/bitwarden_license/src/Sso
RUN npm ci
RUN npm run build
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index f9eeb172c9..6da566ce41 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -5,8 +5,6 @@ FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
# Docker buildx supplies the value for this arg
ARG TARGETPLATFORM
-ARG NODE_VERSION=16.20.2
-ENV NVM_DIR /usr/local/nvm
# Determine proper runtime value for .NET
# We put the value in a file to be read by later layers.
@@ -25,6 +23,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# Set up Node
+ARG NODE_VERSION=16.20.2
+ENV NVM_DIR /usr/local/nvm
RUN mkdir -p $NVM_DIR
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
@@ -51,6 +51,7 @@ COPY Directory.Build.props .
# Restore project dependencies and tools
WORKDIR /source/src/Admin
+RUN npm ci
RUN . /tmp/rid.txt && dotnet restore -r $RID
# Copy required project files
@@ -69,9 +70,8 @@ COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
COPY .git/. ./.git/
-# Build app
+# Build project
WORKDIR /source/src/Admin
-RUN npm ci
RUN npm run build
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Admin --no-restore --no-self-contained -r $RID
@@ -88,17 +88,18 @@ ENV ASPNETCORE_ENVIRONMENT=Production
ENV ASPNETCORE_URLS http://+:5000
EXPOSE 5000
-RUN apt-get update \
- && apt-get install -y --no-install-recommends \
+RUN apt-get update && apt-get install -y --no-install-recommends \
gosu \
curl \
&& rm -rf /var/lib/apt/lists/*
+# Copy image entrypoint
+COPY src/Admin/entrypoint.sh /
+RUN chmod +x /entrypoint.sh
+
# Copy app from the build stage
WORKDIR /app
COPY --from=build /app/Admin ./
-COPY src/Admin/entrypoint.sh /
-RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000 || exit 1
diff --git a/src/Api/Dockerfile b/src/Api/Dockerfile
index 728d1accd2..f065fb4d7c 100644
--- a/src/Api/Dockerfile
+++ b/src/Api/Dockerfile
@@ -43,7 +43,7 @@ COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
COPY .git/. ./.git/
-# Build app
+# Build project
WORKDIR /source/src/Api
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Api --no-restore --no-self-contained -r $RID
diff --git a/src/Billing/Dockerfile b/src/Billing/Dockerfile
index 9c17890bd8..66302ee0b0 100644
--- a/src/Billing/Dockerfile
+++ b/src/Billing/Dockerfile
@@ -39,7 +39,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build app
+# Build project
WORKDIR /source/src/Billing
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Billing --no-restore --no-self-contained -r $RID
diff --git a/src/Events/Dockerfile b/src/Events/Dockerfile
index 88a0b06530..473111a13f 100644
--- a/src/Events/Dockerfile
+++ b/src/Events/Dockerfile
@@ -39,7 +39,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build app
+# Build project
WORKDIR /source/src/Events
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Events --no-restore --no-self-contained -r $RID
diff --git a/src/EventsProcessor/Dockerfile b/src/EventsProcessor/Dockerfile
index 28e1d72357..16c9e8e234 100644
--- a/src/EventsProcessor/Dockerfile
+++ b/src/EventsProcessor/Dockerfile
@@ -39,7 +39,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build app
+# Build project
WORKDIR /source/src/EventsProcessor
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/EventsProcessor --no-restore --no-self-contained -r $RID
diff --git a/src/Icons/Dockerfile b/src/Icons/Dockerfile
index f4780fe779..026abd22f1 100644
--- a/src/Icons/Dockerfile
+++ b/src/Icons/Dockerfile
@@ -39,7 +39,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build app
+# Build project
WORKDIR /source/src/Icons
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Icons --no-restore --no-self-contained -r $RID
diff --git a/src/Identity/Dockerfile b/src/Identity/Dockerfile
index cc2bc1618f..fb04d03c5d 100644
--- a/src/Identity/Dockerfile
+++ b/src/Identity/Dockerfile
@@ -39,7 +39,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build app
+# Build project
WORKDIR /source/src/Identity
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Identity --no-restore --no-self-contained -r $RID
diff --git a/src/Notifications/Dockerfile b/src/Notifications/Dockerfile
index a13d3b4fd9..8e2f59bc93 100644
--- a/src/Notifications/Dockerfile
+++ b/src/Notifications/Dockerfile
@@ -39,7 +39,7 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
-# Build app
+# Build project
WORKDIR /source/src/Notifications
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Notifications --no-restore --no-self-contained -r $RID
diff --git a/util/Attachments/Dockerfile b/util/Attachments/Dockerfile
index 407792b1af..e7a97dc0f0 100644
--- a/util/Attachments/Dockerfile
+++ b/util/Attachments/Dockerfile
@@ -31,7 +31,7 @@ WORKDIR /source
COPY util/Server/. ./util/Server/
COPY .git/. ./.git/
-# Build app
+# Build project
WORKDIR /source/util/Server
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Server --no-restore --no-self-contained -r $RID
diff --git a/util/MsSqlMigratorUtility/Dockerfile b/util/MsSqlMigratorUtility/Dockerfile
index f7c3917fc3..320e14045d 100644
--- a/util/MsSqlMigratorUtility/Dockerfile
+++ b/util/MsSqlMigratorUtility/Dockerfile
@@ -36,7 +36,7 @@ COPY util/Migrator/. ./util/Migrator/
COPY util/MsSqlMigratorUtility/. ./util/MsSqlMigratorUtility/
COPY .git/. ./.git/
-# Build app
+# Build project
WORKDIR /source/util/MsSqlMigratorUtility
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/MsSqlMigratorUtility --no-restore --no-self-contained -r $RID
diff --git a/util/Setup/Dockerfile b/util/Setup/Dockerfile
index 0b91995f7b..21d6aeb46b 100644
--- a/util/Setup/Dockerfile
+++ b/util/Setup/Dockerfile
@@ -35,7 +35,7 @@ COPY util/Migrator/. ./util/Migrator/
COPY util/Setup/. ./util/Setup/
COPY .git/. ./.git/
-# Build app
+# Build project
WORKDIR /source/util/Setup
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Setup --no-restore --no-self-contained -r $RID
From 7562a8e9701951327c1c94a7bd3fdcc997298911 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Tue, 21 Nov 2023 09:16:23 -0500
Subject: [PATCH 078/184] Test order of commands
---
src/Admin/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 6da566ce41..220abd866f 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -51,8 +51,8 @@ COPY Directory.Build.props .
# Restore project dependencies and tools
WORKDIR /source/src/Admin
-RUN npm ci
RUN . /tmp/rid.txt && dotnet restore -r $RID
+RUN npm ci
# Copy required project files
WORKDIR /source
From 62579de436d3b15f899f9cc44246543b14173601 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Tue, 21 Nov 2023 10:33:11 -0500
Subject: [PATCH 079/184] Move commands around in Dockerfile for Admin
---
src/Admin/Dockerfile | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 220abd866f..44abe6c662 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -34,6 +34,11 @@ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | b
ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
+# Copying package.json, package-lock.json, and packages.lock.json
+WORKDIR /source/src/Admin
+COPY package*.json .
+RUN npm ci
+
# Copy csproj files as distinct layers
WORKDIR /source
COPY src/Admin/*.csproj ./src/Admin/
@@ -52,7 +57,6 @@ COPY Directory.Build.props .
# Restore project dependencies and tools
WORKDIR /source/src/Admin
RUN . /tmp/rid.txt && dotnet restore -r $RID
-RUN npm ci
# Copy required project files
WORKDIR /source
From 4980c5041d76da23bc3662d81f1f3f5f6d6fdc76 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Tue, 21 Nov 2023 10:50:35 -0500
Subject: [PATCH 080/184] Fix path
---
src/Admin/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 44abe6c662..c8d5d53285 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -36,7 +36,7 @@ ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
# Copying package.json, package-lock.json, and packages.lock.json
WORKDIR /source/src/Admin
-COPY package*.json .
+COPY src/Admin/package*.json .
RUN npm ci
# Copy csproj files as distinct layers
From d034fa10b08ec8f8b12cfe0dec01705c776074b9 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 8 May 2024 14:32:52 -0400
Subject: [PATCH 081/184] Fix errors
---
.github/workflows/build.yml | 45 ++++++++++---------------------------
1 file changed, 12 insertions(+), 33 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 070a367776..67e95e2092 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -30,8 +30,7 @@ jobs:
build-artifacts:
name: Build artifacts
runs-on: ubuntu-22.04
- needs:
- - lint
+ needs: lint
strategy:
fail-fast: false
matrix:
@@ -193,10 +192,10 @@ jobs:
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
########## ACRs ##########
- - name: Log in to Azure - production subscription
+ - name: Log in to Azure - CI subscription
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
with:
- creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
+ creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
- name: Login to PROD ACR
run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
@@ -241,6 +240,13 @@ jobs:
fi
echo "tags=$TAGS" >> $GITHUB_OUTPUT
+ - name: Generate image full name
+ id: image-name
+ env:
+ IMAGE_TAG: ${{ steps.tag.outputs.image_tag }}
+ PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
+ run: echo "name=${_AZ_REGISTRY}/${PROJECT_NAME}:${IMAGE_TAG}" >> $GITHUB_OUTPUT
+
- name: Build Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
@@ -255,29 +261,6 @@ jobs:
push: true
tags: ${{ steps.image-name.outputs.name }}
- - name: Zip project
- if: ${{ matrix.upload_artifact }}
- working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
- run: |
- mkdir build
- docker run --rm --platform linux/amd64 --volume $(pwd)/build:/temp --entrypoint bash \
- ${{ steps.image-name.outputs.name }} -c "cp -r ./ /temp"
-
- cd build
- zip -r ${{ matrix.project_name }}.zip .
- mv ${{ matrix.project_name }}.zip ../
-
- pwd
- ls -atlh ../
-
- - name: Upload project artifact
- if: ${{ matrix.upload_artifact }}
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
- with:
- name: ${{ matrix.project_name }}.zip
- path: ${{ matrix.base_path }}/${{ matrix.project_name }}/${{ matrix.project_name }}.zip
- if-no-files-found: error
-
- name: Scan Docker image
id: container-scan
uses: anchore/scan-action@3343887d815d7b07465f6fdcd395bd66508d486a # v3.6.4
@@ -291,13 +274,10 @@ jobs:
with:
sarif_file: ${{ steps.container-scan.outputs.sarif }}
- - name: Log out of Docker
- run: docker logout
-
build-stub-swagger:
name: Build Docker-Stub/Swagger
runs-on: ubuntu-22.04
- needs: testing
+ needs: build-docker
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
@@ -422,7 +402,7 @@ jobs:
build-mssqlmigratorutility:
name: Build MSSQL migrator utility
runs-on: ubuntu-22.04
- needs: testing
+ needs: build-docker
defaults:
run:
shell: bash
@@ -548,7 +528,6 @@ jobs:
- lint
- build-artifacts
- build-docker
- - upload
- build-mssqlmigratorutility
- self-host-build
- trigger-k8s-deploy
From 79328da856e03d9f79ffbda14c06d07675b0a806 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 8 May 2024 14:41:19 -0400
Subject: [PATCH 082/184] Remove buid-artifacts job
---
.github/workflows/build.yml | 91 +------------------------------------
1 file changed, 1 insertion(+), 90 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 67e95e2092..df394fa83e 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -27,100 +27,12 @@ jobs:
- name: Verify format
run: dotnet format --verify-no-changes
- build-artifacts:
- name: Build artifacts
- runs-on: ubuntu-22.04
- needs: lint
- strategy:
- fail-fast: false
- matrix:
- include:
- - project_name: Admin
- base_path: ./src
- upload_artifact: true
- - project_name: Api
- base_path: ./src
- - project_name: Billing
- base_path: ./src
- - project_name: Events
- base_path: ./src
- - project_name: EventsProcessor
- base_path: ./src
- - project_name: Icons
- base_path: ./src
- - project_name: Identity
- base_path: ./src
- - project_name: MsSqlMigratorUtility
- base_path: ./util
- dotnet: true
- - project_name: Notifications
- base_path: ./src
- - project_name: Scim
- base_path: ./bitwarden_license/src
- dotnet: true
- - project_name: Server
- base_path: ./util
- - project_name: Setup
- base_path: ./util
- - project_name: Sso
- base_path: ./bitwarden_license/src
- node: true
- steps:
- - name: Check out repo
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
-
- - name: Set up .NET
- uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
-
- - name: Set up Node
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
- with:
- cache: "npm"
- cache-dependency-path: "**/package-lock.json"
- node-version: "16"
-
- - name: Print environment
- run: |
- whoami
- dotnet --info
- node --version
- npm --version
- echo "GitHub ref: $GITHUB_REF"
- echo "GitHub event: $GITHUB_EVENT"
-
- - name: Build node
- if: ${{ matrix.node }}
- working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
- run: |
- npm ci
- npm run build
-
- - name: Publish project
- working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
- run: |
- echo "Publish"
- dotnet publish -c "Release" -o obj/build-output/publish
-
- cd obj/build-output/publish
- zip -r ${{ matrix.project_name }}.zip .
- mv ${{ matrix.project_name }}.zip ../../../
-
- pwd
- ls -atlh ../../../
-
- - name: Upload project artifact
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
- with:
- name: ${{ matrix.project_name }}.zip
- path: ${{ matrix.base_path }}/${{ matrix.project_name }}/${{ matrix.project_name }}.zip
- if-no-files-found: error
-
build-docker:
name: Build Docker images
runs-on: ubuntu-22.04
permissions:
security-events: write
- needs: build-artifacts
+ needs: lint
strategy:
fail-fast: false
matrix:
@@ -526,7 +438,6 @@ jobs:
runs-on: ubuntu-22.04
needs:
- lint
- - build-artifacts
- build-docker
- build-mssqlmigratorutility
- self-host-build
From 798e391b1beba0e26306c2fcd66af38fbbaca821 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 8 May 2024 14:46:49 -0400
Subject: [PATCH 083/184] Add secret retrieval step
---
.github/workflows/build.yml | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index df394fa83e..930b0e36db 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -109,6 +109,13 @@ jobs:
with:
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
+ - name: Retrieve GitHub PAT secrets
+ id: retrieve-secret-pat
+ uses: bitwarden/gh-actions/get-keyvault-secrets@main
+ with:
+ keyvault: "bitwarden-ci"
+ secrets: "github-pat-bitwarden-devops-bot-repo-scope"
+
- name: Login to PROD ACR
run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
@@ -172,6 +179,8 @@ jobs:
linux/arm64
push: true
tags: ${{ steps.image-name.outputs.name }}
+ secrets: |
+ "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
- name: Scan Docker image
id: container-scan
From cea54aad3fabf3a99b79f9179816422b5b1e35d8 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 8 May 2024 14:56:37 -0400
Subject: [PATCH 084/184] Change SP
---
.github/workflows/build.yml | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 930b0e36db..e48598c6f8 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -104,17 +104,10 @@ jobs:
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
########## ACRs ##########
- - name: Log in to Azure - CI subscription
+ - name: Log in to Azure - Production subscription
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
with:
- creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
-
- - name: Retrieve GitHub PAT secrets
- id: retrieve-secret-pat
- uses: bitwarden/gh-actions/get-keyvault-secrets@main
- with:
- keyvault: "bitwarden-ci"
- secrets: "github-pat-bitwarden-devops-bot-repo-scope"
+ creds: ${{ secrets.AZURE_KV_PROD_SERVICE_PRINCIPAL }}
- name: Login to PROD ACR
run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
From ce7d50fe030f1e1c67eec94106dcb5f14c470d4c Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 8 May 2024 15:00:28 -0400
Subject: [PATCH 085/184] Fix SP name
---
.github/workflows/build.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e48598c6f8..897b8da424 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -104,10 +104,10 @@ jobs:
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
########## ACRs ##########
- - name: Log in to Azure - Production subscription
+ - name: Login to Azure - PROD Subscription
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
with:
- creds: ${{ secrets.AZURE_KV_PROD_SERVICE_PRINCIPAL }}
+ creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
- name: Login to PROD ACR
run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
From 42289f140560d4fd5353f4efa58a136650496ae2 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 8 May 2024 15:10:32 -0400
Subject: [PATCH 086/184] Update Attachments Dockerfile to .NET 8
---
util/Attachments/Dockerfile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/util/Attachments/Dockerfile b/util/Attachments/Dockerfile
index e7a97dc0f0..623b5c7466 100644
--- a/util/Attachments/Dockerfile
+++ b/util/Attachments/Dockerfile
@@ -1,7 +1,7 @@
###############################################
# Build stage #
###############################################
-FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
# Docker buildx supplies the value for this arg
ARG TARGETPLATFORM
@@ -40,7 +40,7 @@ WORKDIR /app
###############################################
# App stage #
###############################################
-FROM mcr.microsoft.com/dotnet/aspnet:6.0
+FROM mcr.microsoft.com/dotnet/aspnet:8.0
ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
From 144ecb452bff85098aca6d81f07cb83523fabc43 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 8 May 2024 15:26:35 -0400
Subject: [PATCH 087/184] Add dotnet tool restore step
---
.github/workflows/build.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 897b8da424..fbdf80d1d0 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -207,6 +207,9 @@ jobs:
- name: Login to PROD ACR
run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
+ - name: Restore
+ run: dotnet tool restore
+
- name: Make Docker stubs
if: github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/rc' ||
From dd02ffbe9f4c1ac6f68bfcbda40bc0517306e57d Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 8 May 2024 15:59:57 -0400
Subject: [PATCH 088/184] Try caching
---
.github/workflows/build.yml | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index fbdf80d1d0..ad6fba7ba7 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -153,17 +153,16 @@ jobs:
echo "tags=$TAGS" >> $GITHUB_OUTPUT
- name: Generate image full name
- id: image-name
+ id: cache-name
env:
- IMAGE_TAG: ${{ steps.tag.outputs.image_tag }}
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
- run: echo "name=${_AZ_REGISTRY}/${PROJECT_NAME}:${IMAGE_TAG}" >> $GITHUB_OUTPUT
+ run: echo "name=${_AZ_REGISTRY}/${PROJECT_NAME}:buildcache" >> $GITHUB_OUTPUT
- name: Build Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
- cache-from: type=registry,ref=${{ steps.image-name.outputs.name }}
- cache-to: type=inline
+ cache-from: type=registry,ref=${{ steps.cache-name.outputs.name }}
+ cache-to: type=registry,ref=${{ steps.cache-name.outputs.name}},mode=max
context: .
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
platforms: |
@@ -171,9 +170,7 @@ jobs:
linux/arm/v7,
linux/arm64
push: true
- tags: ${{ steps.image-name.outputs.name }}
- secrets: |
- "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
+ tags: ${{ steps.image-tags.outputs.tags }}
- name: Scan Docker image
id: container-scan
From b303d21c7cdc920d04db35bdfe425946d3eb2d3d Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 23 May 2024 15:18:53 -0400
Subject: [PATCH 089/184] Add justfile
---
.github/workflows/build.yml | 59 +++++++++++++++++++++----------------
justfile | 30 +++++++++++++++++++
2 files changed, 64 insertions(+), 25 deletions(-)
create mode 100644 justfile
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index ad6fba7ba7..6251fb7c48 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -24,8 +24,8 @@ jobs:
- name: Set up .NET
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
- - name: Verify format
- run: dotnet format --verify-no-changes
+ - name: Lint
+ run: just lint
build-docker:
name: Build Docker images
@@ -33,6 +33,9 @@ jobs:
permissions:
security-events: write
needs: lint
+ env:
+ PROJECT_NAME: ${{ matrix.project_name }}
+ BASE_PATH: ${{ matrix.base_path}}
strategy:
fail-fast: false
matrix:
@@ -109,33 +112,39 @@ jobs:
with:
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
- - name: Login to PROD ACR
- run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
+ # - name: Login to PROD ACR
+ # run: az acr login -n ${_AZ_REGISTRY%.azurecr.io}
- ########## Generate image tag and build Docker image ##########
- - name: Generate Docker image tag
- id: tag
- run: |
- if [[ $(grep "pull" <<< "${GITHUB_REF}") ]]; then
- IMAGE_TAG=$(echo "${GITHUB_HEAD_REF}" | sed "s#/#-#g")
- else
- IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g")
- fi
+ # ########## Generate image tag and build Docker image ##########
+ # - name: Generate Docker image tag
+ # id: tag
+ # run: |
+ # if [[ $(grep "pull" <<< "${GITHUB_REF}") ]]; then
+ # IMAGE_TAG=$(echo "${GITHUB_HEAD_REF}" | sed "s#/#-#g")
+ # else
+ # IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g")
+ # fi
- if [[ "$IMAGE_TAG" == "main" ]]; then
- IMAGE_TAG=dev
- fi
+ # if [[ "$IMAGE_TAG" == "main" ]]; then
+ # IMAGE_TAG=dev
+ # fi
- echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
- echo "### :mega: Docker Image Tag: $IMAGE_TAG" >> $GITHUB_STEP_SUMMARY
+ # echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
+ # echo "### :mega: Docker Image Tag: $IMAGE_TAG" >> $GITHUB_STEP_SUMMARY
- - name: Set up project name
- id: setup
- run: |
- PROJECT_NAME=$(echo "${{ matrix.project_name }}" | awk '{print tolower($0)}')
- echo "Matrix name: ${{ matrix.project_name }}"
- echo "PROJECT_NAME: $PROJECT_NAME"
- echo "project_name=$PROJECT_NAME" >> $GITHUB_OUTPUT
+ # - name: Set up project name
+ # id: setup
+ # run: |
+ # PROJECT_NAME=$(echo "${{ matrix.project_name }}" | awk '{print tolower($0)}')
+ # echo "Matrix name: ${{ matrix.project_name }}"
+ # echo "PROJECT_NAME: $PROJECT_NAME"
+ # echo "project_name=$PROJECT_NAME" >> $GITHUB_OUTPUT
+
+ - name: Justfile
+ run: just build
+
+ - name: TEST FAIL
+ run: exit 1
- name: Generate image tags(s)
id: image-tags
diff --git a/justfile b/justfile
new file mode 100644
index 0000000000..7306378ae6
--- /dev/null
+++ b/justfile
@@ -0,0 +1,30 @@
+default:
+ @just --list
+
+all: lint test build upload
+
+lint:
+ dotnet format --verify-no-changes
+
+test:
+ echo "Testing..."
+
+build:
+ # Login to ACR
+ az acr login -n bitwardenprod.azurecr.io
+ if [[ $(grep "pull" <<< "${GITHUB_REF}") ]]; then
+ IMAGE_TAG=$(echo "${GITHUB_HEAD_REF}" | sed "s#/#-#g")
+ else
+ IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g")
+ fi
+
+ if [[ "$IMAGE_TAG" == "main" ]]; then
+ IMAGE_TAG=dev
+ fi
+
+ echo $PROJECT_NAME
+ PROJECT_NAME=$(echo "$PROJECT_NAME" | awk '{print tolower($0)}')
+ echo $PROJECT_NAME
+
+upload:
+ echo "Uploading..."
From f4ca4afbcbde4fbfb9aa542ecbbcd7039066cb07 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 23 May 2024 15:25:19 -0400
Subject: [PATCH 090/184] Add steps to install just
---
.github/workflows/build.yml | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 6251fb7c48..d9837c4cef 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -24,6 +24,11 @@ jobs:
- name: Set up .NET
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
+ - name: Install just
+ uses: taiki-e/install-action@4fedbddde88aab767a45a011661f832d68202716 # v2.33.28
+ with:
+ tool: just
+
- name: Lint
run: just lint
@@ -86,6 +91,11 @@ jobs:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ - name: Install just
+ uses: taiki-e/install-action@4fedbddde88aab767a45a011661f832d68202716 # v2.33.28
+ with:
+ tool: just
+
- name: Check branch to publish
env:
PUBLISH_BRANCHES: "main,rc,hotfix-rc"
From 800c187f51dd22759d7464c5fc7b57e32c63a44c Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 23 May 2024 15:28:18 -0400
Subject: [PATCH 091/184] Disable check failures job
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d9837c4cef..a047db6d24 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -455,7 +455,7 @@ jobs:
check-failures:
name: Check for failures
- if: always()
+ if: false
runs-on: ubuntu-22.04
needs:
- lint
From 8978d9c861985f993a2339bd3516ce14547056e8 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 23 May 2024 16:02:06 -0400
Subject: [PATCH 092/184] Change syntax
---
justfile | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/justfile b/justfile
index 7306378ae6..91388d4a9d 100644
--- a/justfile
+++ b/justfile
@@ -12,19 +12,19 @@ test:
build:
# Login to ACR
az acr login -n bitwardenprod.azurecr.io
- if [[ $(grep "pull" <<< "${GITHUB_REF}") ]]; then
- IMAGE_TAG=$(echo "${GITHUB_HEAD_REF}" | sed "s#/#-#g")
+ if `grep "pull" <<< "${GITHUB_REF}"`; then
+ IMAGE_TAG := `echo "${GITHUB_HEAD_REF}" | sed "s#/#-#g"`
else
- IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g")
+ IMAGE_TAG := `echo "${GITHUB_REF:11}" | sed "s#/#-#g"`
fi
- if [[ "$IMAGE_TAG" == "main" ]]; then
- IMAGE_TAG=dev
+ if "${IMAGE_TAG}" == "main"; then
+ IMAGE_TAG := dev
fi
- echo $PROJECT_NAME
- PROJECT_NAME=$(echo "$PROJECT_NAME" | awk '{print tolower($0)}')
- echo $PROJECT_NAME
+ echo ${PROJECT_NAME}
+ PROJECT_NAME := `echo "$PROJECT_NAME" | awk '{print tolower($0)}'`
+ echo ${PROJECT_NAME}
upload:
echo "Uploading..."
From f3d59bd707efb378bfef8eaafcd32e8c2da34b28 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 23 May 2024 16:15:58 -0400
Subject: [PATCH 093/184] Change spacing
---
justfile | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/justfile b/justfile
index 91388d4a9d..17edb02a8b 100644
--- a/justfile
+++ b/justfile
@@ -13,13 +13,13 @@ build:
# Login to ACR
az acr login -n bitwardenprod.azurecr.io
if `grep "pull" <<< "${GITHUB_REF}"`; then
- IMAGE_TAG := `echo "${GITHUB_HEAD_REF}" | sed "s#/#-#g"`
+ IMAGE_TAG := `echo "${GITHUB_HEAD_REF}" | sed "s#/#-#g"`
else
- IMAGE_TAG := `echo "${GITHUB_REF:11}" | sed "s#/#-#g"`
+ IMAGE_TAG := `echo "${GITHUB_REF:11}" | sed "s#/#-#g"`
fi
if "${IMAGE_TAG}" == "main"; then
- IMAGE_TAG := dev
+ IMAGE_TAG := dev
fi
echo ${PROJECT_NAME}
From af0dc31fe376bc7dc1399d81b4a34098dfaf36dd Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Thu, 23 May 2024 16:27:03 -0400
Subject: [PATCH 094/184] Test new syntax
---
justfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/justfile b/justfile
index 17edb02a8b..d523d41482 100644
--- a/justfile
+++ b/justfile
@@ -12,7 +12,7 @@ test:
build:
# Login to ACR
az acr login -n bitwardenprod.azurecr.io
- if `grep "pull" <<< "${GITHUB_REF}"`; then
+ if `grep "pull"` <<< "${GITHUB_REF}"; then
IMAGE_TAG := `echo "${GITHUB_HEAD_REF}" | sed "s#/#-#g"`
else
IMAGE_TAG := `echo "${GITHUB_REF:11}" | sed "s#/#-#g"`
From bd1602ed989e9b975a849660887b07a8d6b25b59 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Mon, 10 Mar 2025 14:08:38 -0400
Subject: [PATCH 095/184] Fix build workflow
---
.github/workflows/build.yml | 159 +++++++-----------------------------
justfile | 30 -------
2 files changed, 28 insertions(+), 161 deletions(-)
delete mode 100644 justfile
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index bdfa12591d..faac75146f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -34,101 +34,10 @@ jobs:
- name: Verify format
run: dotnet format --verify-no-changes
- build-artifacts:
- name: Build artifacts
- runs-on: ubuntu-22.04
- needs: lint
- strategy:
- fail-fast: false
- matrix:
- include:
- - project_name: Admin
- base_path: ./src
- node: true
- - project_name: Api
- base_path: ./src
- - project_name: Billing
- base_path: ./src
- - project_name: Events
- base_path: ./src
- - project_name: EventsProcessor
- base_path: ./src
- - project_name: Icons
- base_path: ./src
- - project_name: Identity
- base_path: ./src
- - project_name: MsSqlMigratorUtility
- base_path: ./util
- dotnet: true
- - project_name: Notifications
- base_path: ./src
- - project_name: Scim
- base_path: ./bitwarden_license/src
- dotnet: true
- - project_name: Server
- base_path: ./util
- - project_name: Setup
- base_path: ./util
- - project_name: Sso
- base_path: ./bitwarden_license/src
- node: true
- steps:
- - name: Check out repo
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- with:
- ref: ${{ github.event.pull_request.head.sha }}
-
- - name: Set up .NET
- uses: actions/setup-dotnet@87b7050bc53ea08284295505d98d2aa94301e852 # v4.2.0
-
- - name: Set up Node
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
- with:
- cache: "npm"
- cache-dependency-path: "**/package-lock.json"
- node-version: "16"
-
- - name: Print environment
- run: |
- whoami
- dotnet --info
- node --version
- npm --version
- echo "GitHub ref: $GITHUB_REF"
- echo "GitHub event: $GITHUB_EVENT"
-
- - name: Build node
- if: ${{ matrix.node }}
- working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
- run: |
- npm ci
- npm run build
-
- - name: Publish project
- working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
- run: |
- echo "Publish"
- dotnet publish -c "Release" -o obj/build-output/publish
-
- cd obj/build-output/publish
- zip -r ${{ matrix.project_name }}.zip .
- mv ${{ matrix.project_name }}.zip ../../../
-
- pwd
- ls -atlh ../../../
-
- - name: Upload project artifact
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
- with:
- name: ${{ matrix.project_name }}.zip
- path: ${{ matrix.base_path }}/${{ matrix.project_name }}/${{ matrix.project_name }}.zip
- if-no-files-found: error
-
build-docker:
name: Build Docker images
runs-on: ubuntu-22.04
- needs:
- - build-artifacts
+ needs: lint
permissions:
id-token: write
security-events: write
@@ -197,6 +106,13 @@ jobs:
echo "is_publish_branch=false" >> $GITHUB_ENV
fi
+ ########## Set up Docker ##########
+ - name: Set up QEMU emulators
+ uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
+
########## ACRs ##########
- name: Log in to Azure - production subscription
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
@@ -206,25 +122,6 @@ jobs:
- name: Log in to ACR - production subscription
run: az acr login -n bitwardenprod
- - name: Log in to Azure - CI subscription
- uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
- with:
- creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
-
- - name: Retrieve GitHub PAT secrets
- id: retrieve-secret-pat
- uses: bitwarden/gh-actions/get-keyvault-secrets@main
- with:
- keyvault: "bitwarden-ci"
- secrets: "github-pat-bitwarden-devops-bot-repo-scope"
-
- ########## Set up Docker ##########
- - name: Set up QEMU emulators
- uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
-
########## Generate image tag and build Docker image ##########
- name: Generate Docker image tag
id: tag
@@ -235,6 +132,13 @@ jobs:
IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g")
fi
+ if [[ "$IMAGE_TAG" == "main" ]]; then
+ IMAGE_TAG=dev
+ fi
+
+ echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
+ echo "### :mega: Docker Image Tag: $IMAGE_TAG" >> $GITHUB_STEP_SUMMARY
+
- name: Set up project name
id: setup
run: |
@@ -258,25 +162,18 @@ jobs:
fi
echo "tags=$TAGS" >> $GITHUB_OUTPUT
- - name: Get build artifact
- if: ${{ matrix.dotnet }}
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
- with:
- name: ${{ matrix.project_name }}.zip
-
- - name: Set up build artifact
- if: ${{ matrix.dotnet }}
- run: |
- mkdir -p ${{ matrix.base_path}}/${{ matrix.project_name }}/obj/build-output/publish
- unzip ${{ matrix.project_name }}.zip \
- -d ${{ matrix.base_path }}/${{ matrix.project_name }}/obj/build-output/publish
+ - name: Generate image full name
+ id: cache-name
+ env:
+ PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
+ run: echo "name=${_AZ_REGISTRY}/${PROJECT_NAME}:buildcache" >> $GITHUB_OUTPUT
- name: Build Docker image
id: build-docker
uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d # v6.12.0
with:
- # cache-from: type=registry,ref=${{ steps.cache-name.outputs.name }}
- # cache-to: type=registry,ref=${{ steps.cache-name.outputs.name}},mode=max
+ cache-from: type=registry,ref=${{ steps.cache-name.outputs.name }}
+ cache-to: type=registry,ref=${{ steps.cache-name.outputs.name}},mode=max
context: .
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
platforms: |
@@ -560,8 +457,7 @@ jobs:
github.event_name != 'pull_request_target'
&& (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
runs-on: ubuntu-22.04
- needs:
- - build-docker
+ needs: build-docker
steps:
- name: Log in to Azure - CI subscription
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
@@ -594,8 +490,7 @@ jobs:
name: Trigger k8s deploy
if: github.event_name != 'pull_request_target' && github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
- needs:
- - build-docker
+ needs: build-docker
steps:
- name: Log in to Azure - CI subscription
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
@@ -631,8 +526,7 @@ jobs:
github.event_name == 'pull_request_target'
&& contains(github.event.pull_request.labels.*.name, 'ephemeral-environment')
runs-on: ubuntu-24.04
- needs:
- - build-docker
+ needs: build-docker
steps:
- name: Log in to Azure - CI subscription
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
@@ -683,9 +577,12 @@ jobs:
needs:
- lint
- build-docker
+ - build-stub-swagger
- build-mssqlmigratorutility
- self-host-build
- trigger-k8s-deploy
+ - trigger-ee-updates
+ - trigger-ephemeral-environment-sync
steps:
- name: Check if any job failed
if: |
diff --git a/justfile b/justfile
deleted file mode 100644
index d523d41482..0000000000
--- a/justfile
+++ /dev/null
@@ -1,30 +0,0 @@
-default:
- @just --list
-
-all: lint test build upload
-
-lint:
- dotnet format --verify-no-changes
-
-test:
- echo "Testing..."
-
-build:
- # Login to ACR
- az acr login -n bitwardenprod.azurecr.io
- if `grep "pull"` <<< "${GITHUB_REF}"; then
- IMAGE_TAG := `echo "${GITHUB_HEAD_REF}" | sed "s#/#-#g"`
- else
- IMAGE_TAG := `echo "${GITHUB_REF:11}" | sed "s#/#-#g"`
- fi
-
- if "${IMAGE_TAG}" == "main"; then
- IMAGE_TAG := dev
- fi
-
- echo ${PROJECT_NAME}
- PROJECT_NAME := `echo "$PROJECT_NAME" | awk '{print tolower($0)}'`
- echo ${PROJECT_NAME}
-
-upload:
- echo "Uploading..."
From e305e1490d4c95bf3cb325b277a9592e175f113c Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Mon, 10 Mar 2025 14:24:57 -0400
Subject: [PATCH 096/184] Fix ENV in Dockerfiles
---
bitwarden_license/src/Scim/Dockerfile | 2 +-
bitwarden_license/src/Sso/Dockerfile | 8 ++++----
src/Admin/Dockerfile | 8 ++++----
src/Api/Dockerfile | 2 +-
src/Billing/Dockerfile | 2 +-
src/Events/Dockerfile | 2 +-
src/EventsProcessor/Dockerfile | 2 +-
src/Icons/Dockerfile | 2 +-
src/Identity/Dockerfile | 2 +-
src/Notifications/Dockerfile | 2 +-
util/Attachments/Dockerfile | 2 +-
11 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/bitwarden_license/src/Scim/Dockerfile b/bitwarden_license/src/Scim/Dockerfile
index ce2b29e5c9..c3d97e4758 100644
--- a/bitwarden_license/src/Scim/Dockerfile
+++ b/bitwarden_license/src/Scim/Dockerfile
@@ -53,7 +53,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0
ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
ENV ASPNETCORE_ENVIRONMENT=Production
-ENV ASPNETCORE_URLS http://+:5000
+ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
RUN apt-get update \
diff --git a/bitwarden_license/src/Sso/Dockerfile b/bitwarden_license/src/Sso/Dockerfile
index a8343a8048..a25eba6ae9 100644
--- a/bitwarden_license/src/Sso/Dockerfile
+++ b/bitwarden_license/src/Sso/Dockerfile
@@ -6,7 +6,7 @@ FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
# Docker buildx supplies the value for this arg
ARG TARGETPLATFORM
ENV NODE_VERSION=16.20.2
-ENV NVM_DIR /usr/local/nvm
+ENV NVM_DIR=/usr/local/nvm
# Determine proper runtime value for .NET
# We put the value in a file to be read by later layers.
@@ -31,8 +31,8 @@ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | b
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
-ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
-ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
+ENV NODE_PATH=$NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
+ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
# Copy csproj files as distinct layers
WORKDIR /source
@@ -72,7 +72,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0
ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
ENV ASPNETCORE_ENVIRONMENT=Production
-ENV ASPNETCORE_URLS http://+:5000
+ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
RUN apt-get update \
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index d73edcb3d0..c8e54b45e8 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -25,15 +25,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# Set up Node
ARG NODE_VERSION=16.20.2
-ENV NVM_DIR /usr/local/nvm
+ENV NVM_DIR=/usr/local/nvm
RUN mkdir -p $NVM_DIR
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
-ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
-ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
+ENV NODE_PATH=$NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
+ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
# Copying package.json, package-lock.json, and packages.lock.json
WORKDIR /source/src/Admin
@@ -90,7 +90,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0
ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
ENV ASPNETCORE_ENVIRONMENT=Production
-ENV ASPNETCORE_URLS http://+:5000
+ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
RUN apt-get update && apt-get install -y --no-install-recommends \
diff --git a/src/Api/Dockerfile b/src/Api/Dockerfile
index bacfb6a312..d88e31bc22 100644
--- a/src/Api/Dockerfile
+++ b/src/Api/Dockerfile
@@ -57,7 +57,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0
ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
ENV ASPNETCORE_ENVIRONMENT=Production
-ENV ASPNETCORE_URLS http://+:5000
+ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
RUN apt-get update \
diff --git a/src/Billing/Dockerfile b/src/Billing/Dockerfile
index 6b58185585..1e47c2ada9 100644
--- a/src/Billing/Dockerfile
+++ b/src/Billing/Dockerfile
@@ -53,7 +53,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0
ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
ENV ASPNETCORE_ENVIRONMENT=Production
-ENV ASPNETCORE_URLS http://+:5000
+ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
RUN apt-get update \
diff --git a/src/Events/Dockerfile b/src/Events/Dockerfile
index fddc1367e5..6cc8ef2438 100644
--- a/src/Events/Dockerfile
+++ b/src/Events/Dockerfile
@@ -53,7 +53,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0
ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
ENV ASPNETCORE_ENVIRONMENT=Production
-ENV ASPNETCORE_URLS http://+:5000
+ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
RUN apt-get update \
diff --git a/src/EventsProcessor/Dockerfile b/src/EventsProcessor/Dockerfile
index fa302b7375..16a13851aa 100644
--- a/src/EventsProcessor/Dockerfile
+++ b/src/EventsProcessor/Dockerfile
@@ -53,7 +53,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0
ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
ENV ASPNETCORE_ENVIRONMENT=Production
-ENV ASPNETCORE_URLS http://+:5000
+ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
RUN apt-get update \
diff --git a/src/Icons/Dockerfile b/src/Icons/Dockerfile
index f8c26ccbcf..12d8700179 100644
--- a/src/Icons/Dockerfile
+++ b/src/Icons/Dockerfile
@@ -53,7 +53,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0
ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
ENV ASPNETCORE_ENVIRONMENT=Production
-ENV ASPNETCORE_URLS http://+:5000
+ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
RUN apt-get update \
diff --git a/src/Identity/Dockerfile b/src/Identity/Dockerfile
index 1ad1bad8cb..715f779b27 100644
--- a/src/Identity/Dockerfile
+++ b/src/Identity/Dockerfile
@@ -53,7 +53,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0
ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
ENV ASPNETCORE_ENVIRONMENT=Production
-ENV ASPNETCORE_URLS http://+:5000
+ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
RUN apt-get update \
diff --git a/src/Notifications/Dockerfile b/src/Notifications/Dockerfile
index 26ed86d2ce..fc42b07542 100644
--- a/src/Notifications/Dockerfile
+++ b/src/Notifications/Dockerfile
@@ -53,7 +53,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0
ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
ENV ASPNETCORE_ENVIRONMENT=Production
-ENV ASPNETCORE_URLS http://+:5000
+ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
RUN apt-get update \
diff --git a/util/Attachments/Dockerfile b/util/Attachments/Dockerfile
index 623b5c7466..5dc211d148 100644
--- a/util/Attachments/Dockerfile
+++ b/util/Attachments/Dockerfile
@@ -45,7 +45,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0
ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
ENV ASPNETCORE_ENVIRONMENT=Production
-ENV ASPNETCORE_URLS http://+:5000
+ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
RUN apt-get update \
From b89a04d7ff6b9e8f59b29803d2eeb2c7d74fee91 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Mon, 10 Mar 2025 16:01:19 -0400
Subject: [PATCH 097/184] Update
---
src/Admin/Dockerfile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index c8e54b45e8..1f9626530d 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -27,7 +27,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
ARG NODE_VERSION=16.20.2
ENV NVM_DIR=/usr/local/nvm
RUN mkdir -p $NVM_DIR
-RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
+RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
@@ -77,6 +77,7 @@ COPY .git/. ./.git/
# Build project
WORKDIR /source/src/Admin
+RUN npm ci
RUN npm run build
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Admin --no-restore --no-self-contained -r $RID
From 0f5d033b686fd365b1aa307b6c4671a6d4aa9e5a Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Tue, 11 Mar 2025 10:47:11 -0400
Subject: [PATCH 098/184] Add .editorconfig to Dockerfiles
---
bitwarden_license/src/Scim/Dockerfile | 1 +
bitwarden_license/src/Sso/Dockerfile | 1 +
src/Admin/Dockerfile | 1 +
src/Api/Dockerfile | 1 +
src/Billing/Dockerfile | 1 +
src/Events/Dockerfile | 1 +
src/EventsProcessor/Dockerfile | 1 +
src/Icons/Dockerfile | 1 +
src/Identity/Dockerfile | 1 +
src/Notifications/Dockerfile | 1 +
util/Attachments/Dockerfile | 1 +
util/MsSqlMigratorUtility/Dockerfile | 1 +
util/Setup/Dockerfile | 1 +
13 files changed, 13 insertions(+)
diff --git a/bitwarden_license/src/Scim/Dockerfile b/bitwarden_license/src/Scim/Dockerfile
index c3d97e4758..9aa08e880e 100644
--- a/bitwarden_license/src/Scim/Dockerfile
+++ b/bitwarden_license/src/Scim/Dockerfile
@@ -25,6 +25,7 @@ COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
+COPY .editorconfig .
# Restore project dependencies and tools
WORKDIR /source/bitwarden_license/src/Scim
diff --git a/bitwarden_license/src/Sso/Dockerfile b/bitwarden_license/src/Sso/Dockerfile
index a25eba6ae9..f72823bb10 100644
--- a/bitwarden_license/src/Sso/Dockerfile
+++ b/bitwarden_license/src/Sso/Dockerfile
@@ -42,6 +42,7 @@ COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
+COPY .editorconfig .
# Restore project dependencies and tools
WORKDIR /source/bitwarden_license/src/Sso
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 1f9626530d..f419452549 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -54,6 +54,7 @@ COPY util/SqliteMigrations/*.csproj ./util/SqliteMigrations/
COPY bitwarden_license/src/Commercial.Core/*.csproj ./bitwarden_license/src/Commercial.Core/
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/*.csproj ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
COPY Directory.Build.props .
+COPY .editorconfig .
# Restore project dependencies and tools
WORKDIR /source/src/Admin
diff --git a/src/Api/Dockerfile b/src/Api/Dockerfile
index d88e31bc22..53ef5e849c 100644
--- a/src/Api/Dockerfile
+++ b/src/Api/Dockerfile
@@ -27,6 +27,7 @@ COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY bitwarden_license/src/Commercial.Core/*.csproj ./bitwarden_license/src/Commercial.Core/
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/*.csproj ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
COPY Directory.Build.props .
+COPY .editorconfig .
# Restore project dependencies and tools
WORKDIR /source/src/Api
diff --git a/src/Billing/Dockerfile b/src/Billing/Dockerfile
index 1e47c2ada9..11b1539a11 100644
--- a/src/Billing/Dockerfile
+++ b/src/Billing/Dockerfile
@@ -25,6 +25,7 @@ COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
+COPY .editorconfig .
# Restore project dependencies and tools
WORKDIR /source/src/Billing
diff --git a/src/Events/Dockerfile b/src/Events/Dockerfile
index 6cc8ef2438..3d2c119e11 100644
--- a/src/Events/Dockerfile
+++ b/src/Events/Dockerfile
@@ -25,6 +25,7 @@ COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
+COPY .editorconfig .
# Restore project dependencies and tools
WORKDIR /source/src/Events
diff --git a/src/EventsProcessor/Dockerfile b/src/EventsProcessor/Dockerfile
index 16a13851aa..10de833d4e 100644
--- a/src/EventsProcessor/Dockerfile
+++ b/src/EventsProcessor/Dockerfile
@@ -25,6 +25,7 @@ COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
+COPY .editorconfig .
# Restore project dependencies and tools
WORKDIR /source/src/EventsProcessor
diff --git a/src/Icons/Dockerfile b/src/Icons/Dockerfile
index 12d8700179..39dcb01059 100644
--- a/src/Icons/Dockerfile
+++ b/src/Icons/Dockerfile
@@ -25,6 +25,7 @@ COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
+COPY .editorconfig .
# Restore project dependencies and tools
WORKDIR /source/src/Icons
diff --git a/src/Identity/Dockerfile b/src/Identity/Dockerfile
index 715f779b27..aa1d9e4a28 100644
--- a/src/Identity/Dockerfile
+++ b/src/Identity/Dockerfile
@@ -25,6 +25,7 @@ COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
+COPY .editorconfig .
# Restore project dependencies and tools
WORKDIR /source/src/Identity
diff --git a/src/Notifications/Dockerfile b/src/Notifications/Dockerfile
index fc42b07542..6953e8f60c 100644
--- a/src/Notifications/Dockerfile
+++ b/src/Notifications/Dockerfile
@@ -25,6 +25,7 @@ COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
+COPY .editorconfig .
# Restore project dependencies and tools
WORKDIR /source/src/Notifications
diff --git a/util/Attachments/Dockerfile b/util/Attachments/Dockerfile
index 5dc211d148..0b04dc88aa 100644
--- a/util/Attachments/Dockerfile
+++ b/util/Attachments/Dockerfile
@@ -21,6 +21,7 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
WORKDIR /source
COPY util/Server/*.csproj ./util/Server/
COPY Directory.Build.props .
+COPY .editorconfig .
# Restore project dependencies and tools
WORKDIR /source/util/Server
diff --git a/util/MsSqlMigratorUtility/Dockerfile b/util/MsSqlMigratorUtility/Dockerfile
index 60caa23b26..9efc0bbdf9 100644
--- a/util/MsSqlMigratorUtility/Dockerfile
+++ b/util/MsSqlMigratorUtility/Dockerfile
@@ -24,6 +24,7 @@ COPY src/Core/*.csproj ./src/Core/
COPY util/Migrator/*.csproj ./util/Migrator/
COPY util/MsSqlMigratorUtility/*.csproj ./util/MsSqlMigratorUtility/
COPY Directory.Build.props .
+COPY .editorconfig .
# Restore project dependencies and tools
WORKDIR /source/util/MsSqlMigratorUtility
diff --git a/util/Setup/Dockerfile b/util/Setup/Dockerfile
index 8a7c4d1103..a4d292565f 100644
--- a/util/Setup/Dockerfile
+++ b/util/Setup/Dockerfile
@@ -23,6 +23,7 @@ COPY src/Core/*.csproj ./src/Core/
COPY util/Migrator/*.csproj ./util/Migrator/
COPY util/Setup/*.csproj ./util/Setup/
COPY Directory.Build.props .
+COPY .editorconfig .
# Restore project dependencies and tools
WORKDIR /source/util/Setup
From 828076e2bcc9d1e0b78d5cf728d79a5b92d01f37 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 19 Mar 2025 11:52:01 -0400
Subject: [PATCH 099/184] Update runner images
---
.github/workflows/build.yml | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index faac75146f..3117fd7a47 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -20,7 +20,7 @@ jobs:
lint:
name: Lint
- runs-on: ubuntu-22.04
+ runs-on: ubuntu-24.04
needs: check-run
steps:
- name: Check out repo
@@ -36,7 +36,7 @@ jobs:
build-docker:
name: Build Docker images
- runs-on: ubuntu-22.04
+ runs-on: ubuntu-24.04
needs: lint
permissions:
id-token: write
@@ -215,7 +215,7 @@ jobs:
build-stub-swagger:
name: Build Docker-Stub/Swagger
- runs-on: ubuntu-22.04
+ runs-on: ubuntu-24.04
needs: build-docker
steps:
- name: Check out repo
@@ -396,7 +396,7 @@ jobs:
build-mssqlmigratorutility:
name: Build MSSQL migrator utility
- runs-on: ubuntu-22.04
+ runs-on: ubuntu-24.04
needs: lint
defaults:
run:
@@ -456,7 +456,7 @@ jobs:
if: |
github.event_name != 'pull_request_target'
&& (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
- runs-on: ubuntu-22.04
+ runs-on: ubuntu-24.04
needs: build-docker
steps:
- name: Log in to Azure - CI subscription
@@ -489,7 +489,7 @@ jobs:
trigger-k8s-deploy:
name: Trigger k8s deploy
if: github.event_name != 'pull_request_target' && github.ref == 'refs/heads/main'
- runs-on: ubuntu-22.04
+ runs-on: ubuntu-24.04
needs: build-docker
steps:
- name: Log in to Azure - CI subscription
@@ -573,7 +573,7 @@ jobs:
check-failures:
name: Check for failures
if: false
- runs-on: ubuntu-22.04
+ runs-on: ubuntu-24.04
needs:
- lint
- build-docker
From 1fea15c1ffec6587b21ed38d8b508614b7cd1093 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 19 Mar 2025 12:35:59 -0400
Subject: [PATCH 100/184] Remove unused matrix input
---
.github/workflows/build.yml | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 3117fd7a47..b4553c2cec 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -55,38 +55,28 @@ jobs:
base_path: ./util
- project_name: Billing
base_path: ./src
- upload_artifact: true
- project_name: Events
base_path: ./src
- upload_artifact: true
- project_name: EventsProcessor
base_path: ./src
- upload_artifact: true
- project_name: Icons
base_path: ./src
- upload_artifact: true
- project_name: Identity
base_path: ./src
- upload_artifact: true
- project_name: MsSql
base_path: ./util
- project_name: MsSqlMigratorUtility
base_path: ./util
- upload_artifact: true
- project_name: Nginx
base_path: ./util
- project_name: Notifications
base_path: ./src
- upload_artifact: true
- project_name: Scim
base_path: ./bitwarden_license/src
- upload_artifact: true
- project_name: Setup
base_path: ./util
- upload_artifact: true
- project_name: Sso
base_path: ./bitwarden_license/src
- upload_artifact: true
steps:
- name: Check out repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
From 48df98d2b371eeb8d0e76334fee652496814f24a Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 19 Mar 2025 12:50:13 -0400
Subject: [PATCH 101/184] Update text references
---
.github/workflows/build.yml | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index b4553c2cec..d1c64b5788 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -34,8 +34,8 @@ jobs:
- name: Verify format
run: dotnet format --verify-no-changes
- build-docker:
- name: Build Docker images
+ build-container:
+ name: Build container images
runs-on: ubuntu-24.04
needs: lint
permissions:
@@ -112,8 +112,8 @@ jobs:
- name: Log in to ACR - production subscription
run: az acr login -n bitwardenprod
- ########## Generate image tag and build Docker image ##########
- - name: Generate Docker image tag
+ ########## Generate image tag and build container image ##########
+ - name: Generate container image tag
id: tag
run: |
if [[ "${GITHUB_EVENT_NAME}" == "pull_request_target" ]]; then
@@ -127,7 +127,7 @@ jobs:
fi
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
- echo "### :mega: Docker Image Tag: $IMAGE_TAG" >> $GITHUB_STEP_SUMMARY
+ echo "### :mega: Container Image Tag: $IMAGE_TAG" >> $GITHUB_STEP_SUMMARY
- name: Set up project name
id: setup
@@ -158,8 +158,8 @@ jobs:
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
run: echo "name=${_AZ_REGISTRY}/${PROJECT_NAME}:buildcache" >> $GITHUB_OUTPUT
- - name: Build Docker image
- id: build-docker
+ - name: Build Container image
+ id: build-container
uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d # v6.12.0
with:
cache-from: type=registry,ref=${{ steps.cache-name.outputs.name }}
@@ -180,7 +180,7 @@ jobs:
- name: Sign image with Cosign
if: github.event_name != 'pull_request_target' && github.ref == 'refs/heads/main'
env:
- DIGEST: ${{ steps.build-docker.outputs.digest }}
+ DIGEST: ${{ steps.build-container.outputs.digest }}
TAGS: ${{ steps.image-tags.outputs.tags }}
run: |
IFS="," read -a tags <<< "${TAGS}"
@@ -190,7 +190,7 @@ jobs:
done
cosign sign --yes ${images}
- - name: Scan Docker image
+ - name: Scan container image
id: container-scan
uses: anchore/scan-action@abae793926ec39a78ab18002bc7fc45bbbd94342 # v6.0.0
with:
@@ -206,7 +206,7 @@ jobs:
build-stub-swagger:
name: Build Docker-Stub/Swagger
runs-on: ubuntu-24.04
- needs: build-docker
+ needs: build-container
steps:
- name: Check out repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -447,7 +447,7 @@ jobs:
github.event_name != 'pull_request_target'
&& (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
runs-on: ubuntu-24.04
- needs: build-docker
+ needs: build-container
steps:
- name: Log in to Azure - CI subscription
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
@@ -480,7 +480,7 @@ jobs:
name: Trigger k8s deploy
if: github.event_name != 'pull_request_target' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
- needs: build-docker
+ needs: build-container
steps:
- name: Log in to Azure - CI subscription
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
@@ -516,7 +516,7 @@ jobs:
github.event_name == 'pull_request_target'
&& contains(github.event.pull_request.labels.*.name, 'ephemeral-environment')
runs-on: ubuntu-24.04
- needs: build-docker
+ needs: build-container
steps:
- name: Log in to Azure - CI subscription
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
@@ -566,7 +566,7 @@ jobs:
runs-on: ubuntu-24.04
needs:
- lint
- - build-docker
+ - build-container
- build-stub-swagger
- build-mssqlmigratorutility
- self-host-build
From c55672629957af864ba8d1456517d9439984d99f Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 19 Mar 2025 13:02:18 -0400
Subject: [PATCH 102/184] Enable check failures job
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d1c64b5788..7cbeb7f0a3 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -562,7 +562,7 @@ jobs:
check-failures:
name: Check for failures
- if: false
+ if: always()
runs-on: ubuntu-24.04
needs:
- lint
From 3d66acb4ace32faeebb972d42494a88b067196ea Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 19 Mar 2025 13:04:48 -0400
Subject: [PATCH 103/184] Remove extra dotnet inputs from matrix
---
.github/workflows/build.yml | 2 --
1 file changed, 2 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7cbeb7f0a3..285f1f221f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -47,10 +47,8 @@ jobs:
include:
- project_name: Admin
base_path: ./src
- dotnet: true
- project_name: Api
base_path: ./src
- dotnet: true
- project_name: Attachments
base_path: ./util
- project_name: Billing
From 199a1bc681fa949a416477737d2d151ac85043ef Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 19 Mar 2025 13:07:22 -0400
Subject: [PATCH 104/184] Change NVM version
---
bitwarden_license/src/Sso/Dockerfile | 2 +-
src/Admin/Dockerfile | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/bitwarden_license/src/Sso/Dockerfile b/bitwarden_license/src/Sso/Dockerfile
index f72823bb10..9de0519605 100644
--- a/bitwarden_license/src/Sso/Dockerfile
+++ b/bitwarden_license/src/Sso/Dockerfile
@@ -26,7 +26,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# Set up Node
RUN mkdir -p $NVM_DIR
-RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
+RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index f419452549..68a147b7cc 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -5,6 +5,8 @@ FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
# Docker buildx supplies the value for this arg
ARG TARGETPLATFORM
+ENV NODE_VERSION=16.20.2
+ENV NVM_DIR=/usr/local/nvm
# Determine proper runtime value for .NET
# We put the value in a file to be read by later layers.
@@ -24,10 +26,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# Set up Node
-ARG NODE_VERSION=16.20.2
-ENV NVM_DIR=/usr/local/nvm
RUN mkdir -p $NVM_DIR
-RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash \
+RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
From 5faee1528ad5b3842d90b0f5b36b6bd4817dd58a Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Wed, 19 Mar 2025 13:28:47 -0400
Subject: [PATCH 105/184] Add check-run job to each other job
---
.github/workflows/build.yml | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 285f1f221f..8185b42e7f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -37,7 +37,9 @@ jobs:
build-container:
name: Build container images
runs-on: ubuntu-24.04
- needs: lint
+ needs:
+ - check-run
+ - lint
permissions:
id-token: write
security-events: write
@@ -204,7 +206,9 @@ jobs:
build-stub-swagger:
name: Build Docker-Stub/Swagger
runs-on: ubuntu-24.04
- needs: build-container
+ needs:
+ - build-container
+ - check-run
steps:
- name: Check out repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -385,7 +389,9 @@ jobs:
build-mssqlmigratorutility:
name: Build MSSQL migrator utility
runs-on: ubuntu-24.04
- needs: lint
+ needs:
+ - check-run
+ - lint
defaults:
run:
shell: bash
@@ -445,7 +451,9 @@ jobs:
github.event_name != 'pull_request_target'
&& (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
runs-on: ubuntu-24.04
- needs: build-container
+ needs:
+ - build-container
+ - check-run
steps:
- name: Log in to Azure - CI subscription
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
@@ -478,7 +486,9 @@ jobs:
name: Trigger k8s deploy
if: github.event_name != 'pull_request_target' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
- needs: build-container
+ needs:
+ - build-container
+ - check-run
steps:
- name: Log in to Azure - CI subscription
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
@@ -514,7 +524,9 @@ jobs:
github.event_name == 'pull_request_target'
&& contains(github.event.pull_request.labels.*.name, 'ephemeral-environment')
runs-on: ubuntu-24.04
- needs: build-container
+ needs:
+ - build-container
+ - check-run
steps:
- name: Log in to Azure - CI subscription
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
@@ -545,7 +557,9 @@ jobs:
trigger-ephemeral-environment-sync:
name: Trigger Ephemeral Environment Sync
- needs: trigger-ee-updates
+ needs:
+ - check-run
+ - trigger-ee-updates
if: |
github.event_name == 'pull_request_target'
&& contains(github.event.pull_request.labels.*.name, 'ephemeral-environment')
@@ -567,6 +581,7 @@ jobs:
- build-container
- build-stub-swagger
- build-mssqlmigratorutility
+ - check-run
- self-host-build
- trigger-k8s-deploy
- trigger-ee-updates
From 948d8f707d7d98506b6f87f4157721e8b2838c22 Mon Sep 17 00:00:00 2001
From: Nick Krantz <125900171+nick-livefront@users.noreply.github.com>
Date: Thu, 20 Mar 2025 14:41:58 -0500
Subject: [PATCH 106/184] [PM-18858] Security Task email bugs (#5536)
* make "Review at-risk passwords" bold
* add owner and admin email address to the bottom of the security notification email
* fix plurality of text email
---
.../SecurityTasksNotification.html.hbs | 11 ++++-
.../SecurityTasksNotification.text.hbs | 9 ++++
.../Mail/SecurityTaskNotificationViewModel.cs | 2 +
src/Core/Services/IMailService.cs | 2 +-
.../Implementations/HandlebarsMailService.cs | 42 ++++++++++++++++++-
.../NoopImplementations/NoopMailService.cs | 2 +-
.../CreateManyTaskNotificationsCommand.cs | 10 ++++-
7 files changed, 71 insertions(+), 7 deletions(-)
diff --git a/src/Core/MailTemplates/Handlebars/SecurityTasksNotification.html.hbs b/src/Core/MailTemplates/Handlebars/SecurityTasksNotification.html.hbs
index 039806f44b..ca015e3e83 100644
--- a/src/Core/MailTemplates/Handlebars/SecurityTasksNotification.html.hbs
+++ b/src/Core/MailTemplates/Handlebars/SecurityTasksNotification.html.hbs
@@ -15,14 +15,21 @@
+ style="display: table; width:100%; padding-bottom: 24px; text-align: center;" align="center">
+ style="display: inline-block; font-weight: bold; color: #ffffff; text-decoration: none; text-align: center; cursor: pointer; border-radius: 999px; background-color: #175DDC; border-color: #175DDC; border-style: solid; border-width: 10px 20px; margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;">
Review at-risk passwords
|
+
+
+
+ {{formatAdminOwnerEmails AdminOwnerEmails}}
+ |
+
{{/SecurityTasksHtmlLayout}}
diff --git a/src/Core/MailTemplates/Handlebars/SecurityTasksNotification.text.hbs b/src/Core/MailTemplates/Handlebars/SecurityTasksNotification.text.hbs
index ba8650ad10..f5493e4503 100644
--- a/src/Core/MailTemplates/Handlebars/SecurityTasksNotification.text.hbs
+++ b/src/Core/MailTemplates/Handlebars/SecurityTasksNotification.text.hbs
@@ -5,4 +5,13 @@ breach.
Launch the Bitwarden extension to review your at-risk passwords.
Review at-risk passwords ({{{ReviewPasswordsUrl}}})
+
+{{#if (eq (length AdminOwnerEmails) 1)}}
+This request was initiated by {{AdminOwnerEmails.[0]}}.
+{{else}}
+This request was initiated by
+{{#each AdminOwnerEmails}}
+ {{#if @last}}and {{/if}}{{this}}{{#unless @last}}, {{/unless}}
+{{/each}}.
+{{/if}}
{{/SecurityTasksHtmlLayout}}
diff --git a/src/Core/Models/Mail/SecurityTaskNotificationViewModel.cs b/src/Core/Models/Mail/SecurityTaskNotificationViewModel.cs
index 7f93ac2439..8871a53424 100644
--- a/src/Core/Models/Mail/SecurityTaskNotificationViewModel.cs
+++ b/src/Core/Models/Mail/SecurityTaskNotificationViewModel.cs
@@ -8,5 +8,7 @@ public class SecurityTaskNotificationViewModel : BaseMailModel
public bool TaskCountPlural => TaskCount != 1;
+ public IEnumerable AdminOwnerEmails { get; set; }
+
public string ReviewPasswordsUrl => $"{WebVaultUrl}/browser-extension-prompt";
}
diff --git a/src/Core/Services/IMailService.cs b/src/Core/Services/IMailService.cs
index 04b302bad9..e61127c57a 100644
--- a/src/Core/Services/IMailService.cs
+++ b/src/Core/Services/IMailService.cs
@@ -99,5 +99,5 @@ public interface IMailService
string organizationName);
Task SendClaimedDomainUserEmailAsync(ManagedUserDomainClaimedEmails emailList);
Task SendDeviceApprovalRequestedNotificationEmailAsync(IEnumerable adminEmails, Guid organizationId, string email, string userName);
- Task SendBulkSecurityTaskNotificationsAsync(Organization org, IEnumerable securityTaskNotifications);
+ Task SendBulkSecurityTaskNotificationsAsync(Organization org, IEnumerable securityTaskNotifications, IEnumerable adminOwnerEmails);
}
diff --git a/src/Core/Services/Implementations/HandlebarsMailService.cs b/src/Core/Services/Implementations/HandlebarsMailService.cs
index 588365f8c9..edb99809f7 100644
--- a/src/Core/Services/Implementations/HandlebarsMailService.cs
+++ b/src/Core/Services/Implementations/HandlebarsMailService.cs
@@ -740,6 +740,45 @@ public class HandlebarsMailService : IMailService
var clickTrackingText = (clickTrackingOff ? "clicktracking=off" : string.Empty);
writer.WriteSafeString($"{text}");
});
+
+ // Construct markup for admin and owner email addresses.
+ // Using conditionals within the handlebar syntax was including extra spaces around
+ // concatenated strings, which this helper avoids.
+ Handlebars.RegisterHelper("formatAdminOwnerEmails", (writer, context, parameters) =>
+ {
+ if (parameters.Length == 0)
+ {
+ writer.WriteSafeString(string.Empty);
+ return;
+ }
+
+ var emailList = ((IEnumerable)parameters[0]).ToList();
+ if (emailList.Count == 0)
+ {
+ writer.WriteSafeString(string.Empty);
+ return;
+ }
+
+ string constructAnchorElement(string email)
+ {
+ return $"{email}";
+ }
+
+ var outputMessage = "This request was initiated by ";
+
+ if (emailList.Count == 1)
+ {
+ outputMessage += $"{constructAnchorElement(emailList[0])}.";
+ }
+ else
+ {
+ outputMessage += string.Join(", ", emailList.Take(emailList.Count - 1)
+ .Select(email => constructAnchorElement(email)));
+ outputMessage += $", and {constructAnchorElement(emailList.Last())}.";
+ }
+
+ writer.WriteSafeString($"{outputMessage}");
+ });
}
public async Task SendEmergencyAccessInviteEmailAsync(EmergencyAccess emergencyAccess, string name, string token)
@@ -1201,7 +1240,7 @@ public class HandlebarsMailService : IMailService
await _mailDeliveryService.SendEmailAsync(message);
}
- public async Task SendBulkSecurityTaskNotificationsAsync(Organization org, IEnumerable securityTaskNotifications)
+ public async Task SendBulkSecurityTaskNotificationsAsync(Organization org, IEnumerable securityTaskNotifications, IEnumerable adminOwnerEmails)
{
MailQueueMessage CreateMessage(UserSecurityTasksCount notification)
{
@@ -1211,6 +1250,7 @@ public class HandlebarsMailService : IMailService
{
OrgName = CoreHelpers.SanitizeForEmail(sanitizedOrgName, false),
TaskCount = notification.TaskCount,
+ AdminOwnerEmails = adminOwnerEmails,
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
};
message.Category = "SecurityTasksNotification";
diff --git a/src/Core/Services/NoopImplementations/NoopMailService.cs b/src/Core/Services/NoopImplementations/NoopMailService.cs
index 776dd07f19..d829fbbacb 100644
--- a/src/Core/Services/NoopImplementations/NoopMailService.cs
+++ b/src/Core/Services/NoopImplementations/NoopMailService.cs
@@ -324,7 +324,7 @@ public class NoopMailService : IMailService
return Task.FromResult(0);
}
- public Task SendBulkSecurityTaskNotificationsAsync(Organization org, IEnumerable securityTaskNotifications)
+ public Task SendBulkSecurityTaskNotificationsAsync(Organization org, IEnumerable securityTaskNotifications, IEnumerable adminOwnerEmails)
{
return Task.FromResult(0);
}
diff --git a/src/Core/Vault/Commands/CreateManyTaskNotificationsCommand.cs b/src/Core/Vault/Commands/CreateManyTaskNotificationsCommand.cs
index f939816301..a335b059a4 100644
--- a/src/Core/Vault/Commands/CreateManyTaskNotificationsCommand.cs
+++ b/src/Core/Vault/Commands/CreateManyTaskNotificationsCommand.cs
@@ -17,19 +17,22 @@ public class CreateManyTaskNotificationsCommand : ICreateManyTaskNotificationsCo
private readonly IMailService _mailService;
private readonly ICreateNotificationCommand _createNotificationCommand;
private readonly IPushNotificationService _pushNotificationService;
+ private readonly IOrganizationUserRepository _organizationUserRepository;
public CreateManyTaskNotificationsCommand(
IGetSecurityTasksNotificationDetailsQuery getSecurityTasksNotificationDetailsQuery,
IOrganizationRepository organizationRepository,
IMailService mailService,
ICreateNotificationCommand createNotificationCommand,
- IPushNotificationService pushNotificationService)
+ IPushNotificationService pushNotificationService,
+ IOrganizationUserRepository organizationUserRepository)
{
_getSecurityTasksNotificationDetailsQuery = getSecurityTasksNotificationDetailsQuery;
_organizationRepository = organizationRepository;
_mailService = mailService;
_createNotificationCommand = createNotificationCommand;
_pushNotificationService = pushNotificationService;
+ _organizationUserRepository = organizationUserRepository;
}
public async Task CreateAsync(Guid orgId, IEnumerable securityTasks)
@@ -45,8 +48,11 @@ public class CreateManyTaskNotificationsCommand : ICreateManyTaskNotificationsCo
}).ToList();
var organization = await _organizationRepository.GetByIdAsync(orgId);
+ var orgAdminEmails = await _organizationUserRepository.GetManyDetailsByRoleAsync(orgId, OrganizationUserType.Admin);
+ var orgOwnerEmails = await _organizationUserRepository.GetManyDetailsByRoleAsync(orgId, OrganizationUserType.Owner);
+ var orgAdminAndOwnerEmails = orgAdminEmails.Concat(orgOwnerEmails).Select(x => x.Email).Distinct().ToList();
- await _mailService.SendBulkSecurityTaskNotificationsAsync(organization, userTaskCount);
+ await _mailService.SendBulkSecurityTaskNotificationsAsync(organization, userTaskCount, orgAdminAndOwnerEmails);
// Break securityTaskCiphers into separate lists by user Id
var securityTaskCiphersByUser = securityTaskCiphers.GroupBy(x => x.UserId)
From 5d549402c713f179781c9680952ac95186055934 Mon Sep 17 00:00:00 2001
From: Github Actions
Date: Fri, 21 Mar 2025 10:15:22 +0000
Subject: [PATCH 107/184] Bumped version to 2025.3.3
---
Directory.Build.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index cbe9786d65..2ede6ad8d1 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -3,7 +3,7 @@
net8.0
- 2025.3.2
+ 2025.3.3
Bit.$(MSBuildProjectName)
enable
From c7c6528faaa2fb6f20b9e3e9186404405986abe0 Mon Sep 17 00:00:00 2001
From: Brandon Treston
Date: Fri, 21 Mar 2025 10:07:55 -0400
Subject: [PATCH 108/184] Ac/pm 18240 implement policy requirement for reset
password policy (#5521)
* wip
* fix test
* fix test
* refactor
* fix factory method and tests
* cleanup
* refactor
* update copy
* cleanup
---
.../OrganizationUsersController.cs | 11 ++-
.../Controllers/OrganizationsController.cs | 15 ++-
.../ResetPasswordPolicyRequirement.cs | 46 ++++++++++
.../PolicyServiceCollectionExtensions.cs | 1 +
.../Implementations/OrganizationService.cs | 29 ++++--
.../OrganizationUsersControllerTests.cs | 91 +++++++++++++++++++
.../OrganizationsControllerTests.cs | 57 ++++++++++++
...etPasswordPolicyRequirementFactoryTests.cs | 37 ++++++++
8 files changed, 277 insertions(+), 10 deletions(-)
create mode 100644 src/Core/AdminConsole/OrganizationFeatures/Policies/PolicyRequirements/ResetPasswordPolicyRequirement.cs
create mode 100644 test/Core.Test/AdminConsole/OrganizationFeatures/Policies/PolicyRequirements/ResetPasswordPolicyRequirementFactoryTests.cs
diff --git a/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs b/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs
index 5a73e57204..cc7f2314fd 100644
--- a/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs
+++ b/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs
@@ -8,6 +8,8 @@ using Bit.Core.AdminConsole.Enums;
using Bit.Core.AdminConsole.Models.Data.Organizations.Policies;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Authorization;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces;
+using Bit.Core.AdminConsole.OrganizationFeatures.Policies;
+using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyRequirements;
using Bit.Core.AdminConsole.OrganizationFeatures.Shared.Authorization;
using Bit.Core.AdminConsole.Repositories;
using Bit.Core.Auth.Enums;
@@ -55,6 +57,7 @@ public class OrganizationUsersController : Controller
private readonly IRemoveOrganizationUserCommand _removeOrganizationUserCommand;
private readonly IDeleteManagedOrganizationUserAccountCommand _deleteManagedOrganizationUserAccountCommand;
private readonly IGetOrganizationUsersManagementStatusQuery _getOrganizationUsersManagementStatusQuery;
+ private readonly IPolicyRequirementQuery _policyRequirementQuery;
private readonly IFeatureService _featureService;
private readonly IPricingClient _pricingClient;
@@ -79,6 +82,7 @@ public class OrganizationUsersController : Controller
IRemoveOrganizationUserCommand removeOrganizationUserCommand,
IDeleteManagedOrganizationUserAccountCommand deleteManagedOrganizationUserAccountCommand,
IGetOrganizationUsersManagementStatusQuery getOrganizationUsersManagementStatusQuery,
+ IPolicyRequirementQuery policyRequirementQuery,
IFeatureService featureService,
IPricingClient pricingClient)
{
@@ -102,6 +106,7 @@ public class OrganizationUsersController : Controller
_removeOrganizationUserCommand = removeOrganizationUserCommand;
_deleteManagedOrganizationUserAccountCommand = deleteManagedOrganizationUserAccountCommand;
_getOrganizationUsersManagementStatusQuery = getOrganizationUsersManagementStatusQuery;
+ _policyRequirementQuery = policyRequirementQuery;
_featureService = featureService;
_pricingClient = pricingClient;
}
@@ -315,11 +320,13 @@ public class OrganizationUsersController : Controller
throw new UnauthorizedAccessException();
}
- var useMasterPasswordPolicy = await ShouldHandleResetPasswordAsync(orgId);
+ var useMasterPasswordPolicy = _featureService.IsEnabled(FeatureFlagKeys.PolicyRequirements)
+ ? (await _policyRequirementQuery.GetAsync(user.Id)).AutoEnrollEnabled(orgId)
+ : await ShouldHandleResetPasswordAsync(orgId);
if (useMasterPasswordPolicy && string.IsNullOrWhiteSpace(model.ResetPasswordKey))
{
- throw new BadRequestException(string.Empty, "Master Password reset is required, but not provided.");
+ throw new BadRequestException("Master Password reset is required, but not provided.");
}
await _acceptOrgUserCommand.AcceptOrgUserByEmailTokenAsync(organizationUserId, user, model.Token, _userService);
diff --git a/src/Api/AdminConsole/Controllers/OrganizationsController.cs b/src/Api/AdminConsole/Controllers/OrganizationsController.cs
index 34da3de10c..9fa9cb6672 100644
--- a/src/Api/AdminConsole/Controllers/OrganizationsController.cs
+++ b/src/Api/AdminConsole/Controllers/OrganizationsController.cs
@@ -16,6 +16,8 @@ using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationApiKeys.Interfaces;
using Bit.Core.AdminConsole.OrganizationFeatures.Organizations;
using Bit.Core.AdminConsole.OrganizationFeatures.Organizations.Interfaces;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces;
+using Bit.Core.AdminConsole.OrganizationFeatures.Policies;
+using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyRequirements;
using Bit.Core.AdminConsole.Repositories;
using Bit.Core.Auth.Enums;
using Bit.Core.Auth.Repositories;
@@ -61,6 +63,7 @@ public class OrganizationsController : Controller
private readonly IRemoveOrganizationUserCommand _removeOrganizationUserCommand;
private readonly ICloudOrganizationSignUpCommand _cloudOrganizationSignUpCommand;
private readonly IOrganizationDeleteCommand _organizationDeleteCommand;
+ private readonly IPolicyRequirementQuery _policyRequirementQuery;
private readonly IPricingClient _pricingClient;
public OrganizationsController(
@@ -84,6 +87,7 @@ public class OrganizationsController : Controller
IRemoveOrganizationUserCommand removeOrganizationUserCommand,
ICloudOrganizationSignUpCommand cloudOrganizationSignUpCommand,
IOrganizationDeleteCommand organizationDeleteCommand,
+ IPolicyRequirementQuery policyRequirementQuery,
IPricingClient pricingClient)
{
_organizationRepository = organizationRepository;
@@ -106,6 +110,7 @@ public class OrganizationsController : Controller
_removeOrganizationUserCommand = removeOrganizationUserCommand;
_cloudOrganizationSignUpCommand = cloudOrganizationSignUpCommand;
_organizationDeleteCommand = organizationDeleteCommand;
+ _policyRequirementQuery = policyRequirementQuery;
_pricingClient = pricingClient;
}
@@ -163,8 +168,13 @@ public class OrganizationsController : Controller
throw new NotFoundException();
}
- var resetPasswordPolicy =
- await _policyRepository.GetByOrganizationIdTypeAsync(organization.Id, PolicyType.ResetPassword);
+ if (_featureService.IsEnabled(FeatureFlagKeys.PolicyRequirements))
+ {
+ var resetPasswordPolicyRequirement = await _policyRequirementQuery.GetAsync(user.Id);
+ return new OrganizationAutoEnrollStatusResponseModel(organization.Id, resetPasswordPolicyRequirement.AutoEnrollEnabled(organization.Id));
+ }
+
+ var resetPasswordPolicy = await _policyRepository.GetByOrganizationIdTypeAsync(organization.Id, PolicyType.ResetPassword);
if (resetPasswordPolicy == null || !resetPasswordPolicy.Enabled || resetPasswordPolicy.Data == null)
{
return new OrganizationAutoEnrollStatusResponseModel(organization.Id, false);
@@ -172,6 +182,7 @@ public class OrganizationsController : Controller
var data = JsonSerializer.Deserialize(resetPasswordPolicy.Data, JsonHelpers.IgnoreCase);
return new OrganizationAutoEnrollStatusResponseModel(organization.Id, data?.AutoEnrollEnabled ?? false);
+
}
[HttpPost("")]
diff --git a/src/Core/AdminConsole/OrganizationFeatures/Policies/PolicyRequirements/ResetPasswordPolicyRequirement.cs b/src/Core/AdminConsole/OrganizationFeatures/Policies/PolicyRequirements/ResetPasswordPolicyRequirement.cs
new file mode 100644
index 0000000000..4feef1b088
--- /dev/null
+++ b/src/Core/AdminConsole/OrganizationFeatures/Policies/PolicyRequirements/ResetPasswordPolicyRequirement.cs
@@ -0,0 +1,46 @@
+using Bit.Core.AdminConsole.Enums;
+using Bit.Core.AdminConsole.Models.Data.Organizations.Policies;
+using Bit.Core.Enums;
+
+namespace Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyRequirements;
+
+///
+/// Policy requirements for the Account recovery administration policy.
+///
+public class ResetPasswordPolicyRequirement : IPolicyRequirement
+{
+ ///
+ /// List of Organization Ids that require automatic enrollment in password recovery.
+ ///
+ private IEnumerable _autoEnrollOrganizations;
+ public IEnumerable AutoEnrollOrganizations { init => _autoEnrollOrganizations = value; }
+
+ ///
+ /// Returns true if provided organizationId requires automatic enrollment in password recovery.
+ ///
+ public bool AutoEnrollEnabled(Guid organizationId)
+ {
+ return _autoEnrollOrganizations.Contains(organizationId);
+ }
+
+
+}
+
+public class ResetPasswordPolicyRequirementFactory : BasePolicyRequirementFactory
+{
+ public override PolicyType PolicyType => PolicyType.ResetPassword;
+
+ protected override bool ExemptProviders => false;
+
+ protected override IEnumerable ExemptRoles => [];
+
+ public override ResetPasswordPolicyRequirement Create(IEnumerable policyDetails)
+ {
+ var result = policyDetails
+ .Where(p => p.GetDataModel().AutoEnrollEnabled)
+ .Select(p => p.OrganizationId)
+ .ToHashSet();
+
+ return new ResetPasswordPolicyRequirement() { AutoEnrollOrganizations = result };
+ }
+}
diff --git a/src/Core/AdminConsole/OrganizationFeatures/Policies/PolicyServiceCollectionExtensions.cs b/src/Core/AdminConsole/OrganizationFeatures/Policies/PolicyServiceCollectionExtensions.cs
index 6c698f9ffc..d386006ad2 100644
--- a/src/Core/AdminConsole/OrganizationFeatures/Policies/PolicyServiceCollectionExtensions.cs
+++ b/src/Core/AdminConsole/OrganizationFeatures/Policies/PolicyServiceCollectionExtensions.cs
@@ -33,5 +33,6 @@ public static class PolicyServiceCollectionExtensions
{
services.AddScoped, DisableSendPolicyRequirementFactory>();
services.AddScoped, SendOptionsPolicyRequirementFactory>();
+ services.AddScoped, ResetPasswordPolicyRequirementFactory>();
}
}
diff --git a/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs b/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs
index 1b44eea496..772b407951 100644
--- a/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs
+++ b/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs
@@ -6,6 +6,8 @@ using Bit.Core.AdminConsole.Enums.Provider;
using Bit.Core.AdminConsole.Models.Business;
using Bit.Core.AdminConsole.Models.Data.Organizations.Policies;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces;
+using Bit.Core.AdminConsole.OrganizationFeatures.Policies;
+using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyRequirements;
using Bit.Core.AdminConsole.Repositories;
using Bit.Core.AdminConsole.Services;
using Bit.Core.Auth.Enums;
@@ -76,6 +78,7 @@ public class OrganizationService : IOrganizationService
private readonly IOrganizationBillingService _organizationBillingService;
private readonly IHasConfirmedOwnersExceptQuery _hasConfirmedOwnersExceptQuery;
private readonly IPricingClient _pricingClient;
+ private readonly IPolicyRequirementQuery _policyRequirementQuery;
public OrganizationService(
IOrganizationRepository organizationRepository,
@@ -111,7 +114,8 @@ public class OrganizationService : IOrganizationService
ITwoFactorIsEnabledQuery twoFactorIsEnabledQuery,
IOrganizationBillingService organizationBillingService,
IHasConfirmedOwnersExceptQuery hasConfirmedOwnersExceptQuery,
- IPricingClient pricingClient)
+ IPricingClient pricingClient,
+ IPolicyRequirementQuery policyRequirementQuery)
{
_organizationRepository = organizationRepository;
_organizationUserRepository = organizationUserRepository;
@@ -147,6 +151,7 @@ public class OrganizationService : IOrganizationService
_organizationBillingService = organizationBillingService;
_hasConfirmedOwnersExceptQuery = hasConfirmedOwnersExceptQuery;
_pricingClient = pricingClient;
+ _policyRequirementQuery = policyRequirementQuery;
}
public async Task ReplacePaymentMethodAsync(Guid organizationId, string paymentToken,
@@ -1353,13 +1358,25 @@ public class OrganizationService : IOrganizationService
}
// Block the user from withdrawal if auto enrollment is enabled
- if (resetPasswordKey == null && resetPasswordPolicy.Data != null)
+ if (_featureService.IsEnabled(FeatureFlagKeys.PolicyRequirements))
{
- var data = JsonSerializer.Deserialize(resetPasswordPolicy.Data, JsonHelpers.IgnoreCase);
-
- if (data?.AutoEnrollEnabled ?? false)
+ var resetPasswordPolicyRequirement = await _policyRequirementQuery.GetAsync(userId);
+ if (resetPasswordKey == null && resetPasswordPolicyRequirement.AutoEnrollEnabled(organizationId))
{
- throw new BadRequestException("Due to an Enterprise Policy, you are not allowed to withdraw from Password Reset.");
+ throw new BadRequestException("Due to an Enterprise Policy, you are not allowed to withdraw from account recovery.");
+ }
+
+ }
+ else
+ {
+ if (resetPasswordKey == null && resetPasswordPolicy.Data != null)
+ {
+ var data = JsonSerializer.Deserialize(resetPasswordPolicy.Data, JsonHelpers.IgnoreCase);
+
+ if (data?.AutoEnrollEnabled ?? false)
+ {
+ throw new BadRequestException("Due to an Enterprise Policy, you are not allowed to withdraw from account recovery.");
+ }
}
}
diff --git a/test/Api.Test/AdminConsole/Controllers/OrganizationUsersControllerTests.cs b/test/Api.Test/AdminConsole/Controllers/OrganizationUsersControllerTests.cs
index e3071bd227..a19560ecee 100644
--- a/test/Api.Test/AdminConsole/Controllers/OrganizationUsersControllerTests.cs
+++ b/test/Api.Test/AdminConsole/Controllers/OrganizationUsersControllerTests.cs
@@ -7,6 +7,8 @@ using Bit.Core.AdminConsole.Entities;
using Bit.Core.AdminConsole.Enums;
using Bit.Core.AdminConsole.Models.Data.Organizations.Policies;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces;
+using Bit.Core.AdminConsole.OrganizationFeatures.Policies;
+using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyRequirements;
using Bit.Core.AdminConsole.Repositories;
using Bit.Core.Auth.Entities;
using Bit.Core.Auth.Repositories;
@@ -424,4 +426,93 @@ public class OrganizationUsersControllerTests
.GetManyDetailsByOrganizationAsync(organizationAbility.Id, Arg.Any(), Arg.Any())
.Returns(organizationUsers);
}
+
+ [Theory]
+ [BitAutoData]
+ public async Task Accept_WhenOrganizationUsePoliciesIsEnabledAndResetPolicyIsEnabled_WithPolicyRequirementsEnabled_ShouldHandleResetPassword(Guid orgId, Guid orgUserId,
+ OrganizationUserAcceptRequestModel model, User user, SutProvider sutProvider)
+ {
+ // Arrange
+ var applicationCacheService = sutProvider.GetDependency();
+ applicationCacheService.GetOrganizationAbilityAsync(orgId).Returns(new OrganizationAbility { UsePolicies = true });
+
+ sutProvider.GetDependency().IsEnabled(FeatureFlagKeys.PolicyRequirements).Returns(true);
+
+ var policy = new Policy
+ {
+ Enabled = true,
+ Data = CoreHelpers.ClassToJsonData(new ResetPasswordDataModel { AutoEnrollEnabled = true, }),
+ };
+ var userService = sutProvider.GetDependency();
+ userService.GetUserByPrincipalAsync(default).ReturnsForAnyArgs(user);
+
+ var policyRequirementQuery = sutProvider.GetDependency();
+
+ var policyRepository = sutProvider.GetDependency();
+
+ var policyRequirement = new ResetPasswordPolicyRequirement { AutoEnrollOrganizations = [orgId] };
+
+ policyRequirementQuery.GetAsync(user.Id).Returns(policyRequirement);
+
+ // Act
+ await sutProvider.Sut.Accept(orgId, orgUserId, model);
+
+ // Assert
+ await sutProvider.GetDependency().Received(1)
+ .AcceptOrgUserByEmailTokenAsync(orgUserId, user, model.Token, userService);
+ await sutProvider.GetDependency().Received(1)
+ .UpdateUserResetPasswordEnrollmentAsync(orgId, user.Id, model.ResetPasswordKey, user.Id);
+
+ await userService.Received(1).GetUserByPrincipalAsync(default);
+ await applicationCacheService.Received(0).GetOrganizationAbilityAsync(orgId);
+ await policyRepository.Received(0).GetByOrganizationIdTypeAsync(orgId, PolicyType.ResetPassword);
+ await policyRequirementQuery.Received(1).GetAsync(user.Id);
+ Assert.True(policyRequirement.AutoEnrollEnabled(orgId));
+ }
+
+ [Theory]
+ [BitAutoData]
+ public async Task Accept_WithInvalidModelResetPasswordKey_WithPolicyRequirementsEnabled_ThrowsBadRequestException(Guid orgId, Guid orgUserId,
+ OrganizationUserAcceptRequestModel model, User user, SutProvider sutProvider)
+ {
+ // Arrange
+ model.ResetPasswordKey = " ";
+ var applicationCacheService = sutProvider.GetDependency();
+ applicationCacheService.GetOrganizationAbilityAsync(orgId).Returns(new OrganizationAbility { UsePolicies = true });
+
+ sutProvider.GetDependency().IsEnabled(FeatureFlagKeys.PolicyRequirements).Returns(true);
+
+ var policy = new Policy
+ {
+ Enabled = true,
+ Data = CoreHelpers.ClassToJsonData(new ResetPasswordDataModel { AutoEnrollEnabled = true, }),
+ };
+ var userService = sutProvider.GetDependency();
+ userService.GetUserByPrincipalAsync(default).ReturnsForAnyArgs(user);
+
+ var policyRepository = sutProvider.GetDependency();
+
+ var policyRequirementQuery = sutProvider.GetDependency();
+
+ var policyRequirement = new ResetPasswordPolicyRequirement { AutoEnrollOrganizations = [orgId] };
+
+ policyRequirementQuery.GetAsync(user.Id).Returns(policyRequirement);
+
+ // Act
+ var exception = await Assert.ThrowsAsync(() =>
+ sutProvider.Sut.Accept(orgId, orgUserId, model));
+
+ // Assert
+ await sutProvider.GetDependency().Received(0)
+ .AcceptOrgUserByEmailTokenAsync(orgUserId, user, model.Token, userService);
+ await sutProvider.GetDependency().Received(0)
+ .UpdateUserResetPasswordEnrollmentAsync(orgId, user.Id, model.ResetPasswordKey, user.Id);
+
+ await userService.Received(1).GetUserByPrincipalAsync(default);
+ await applicationCacheService.Received(0).GetOrganizationAbilityAsync(orgId);
+ await policyRepository.Received(0).GetByOrganizationIdTypeAsync(orgId, PolicyType.ResetPassword);
+ await policyRequirementQuery.Received(1).GetAsync(user.Id);
+
+ Assert.Equal("Master Password reset is required, but not provided.", exception.Message);
+ }
}
diff --git a/test/Api.Test/AdminConsole/Controllers/OrganizationsControllerTests.cs b/test/Api.Test/AdminConsole/Controllers/OrganizationsControllerTests.cs
index b0906ddc43..8e6d2ce27b 100644
--- a/test/Api.Test/AdminConsole/Controllers/OrganizationsControllerTests.cs
+++ b/test/Api.Test/AdminConsole/Controllers/OrganizationsControllerTests.cs
@@ -4,12 +4,15 @@ using Bit.Api.AdminConsole.Controllers;
using Bit.Api.Auth.Models.Request.Accounts;
using Bit.Core;
using Bit.Core.AdminConsole.Entities;
+using Bit.Core.AdminConsole.Enums;
using Bit.Core.AdminConsole.Enums.Provider;
using Bit.Core.AdminConsole.Models.Business.Tokenables;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationApiKeys.Interfaces;
using Bit.Core.AdminConsole.OrganizationFeatures.Organizations;
using Bit.Core.AdminConsole.OrganizationFeatures.Organizations.Interfaces;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces;
+using Bit.Core.AdminConsole.OrganizationFeatures.Policies;
+using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyRequirements;
using Bit.Core.AdminConsole.Repositories;
using Bit.Core.Auth.Entities;
using Bit.Core.Auth.Enums;
@@ -55,6 +58,7 @@ public class OrganizationsControllerTests : IDisposable
private readonly IRemoveOrganizationUserCommand _removeOrganizationUserCommand;
private readonly ICloudOrganizationSignUpCommand _cloudOrganizationSignUpCommand;
private readonly IOrganizationDeleteCommand _organizationDeleteCommand;
+ private readonly IPolicyRequirementQuery _policyRequirementQuery;
private readonly IPricingClient _pricingClient;
private readonly OrganizationsController _sut;
@@ -80,6 +84,7 @@ public class OrganizationsControllerTests : IDisposable
_removeOrganizationUserCommand = Substitute.For();
_cloudOrganizationSignUpCommand = Substitute.For();
_organizationDeleteCommand = Substitute.For();
+ _policyRequirementQuery = Substitute.For();
_pricingClient = Substitute.For();
_sut = new OrganizationsController(
@@ -103,6 +108,7 @@ public class OrganizationsControllerTests : IDisposable
_removeOrganizationUserCommand,
_cloudOrganizationSignUpCommand,
_organizationDeleteCommand,
+ _policyRequirementQuery,
_pricingClient);
}
@@ -236,4 +242,55 @@ public class OrganizationsControllerTests : IDisposable
await _organizationDeleteCommand.Received(1).DeleteAsync(organization);
}
+
+ [Theory, AutoData]
+ public async Task GetAutoEnrollStatus_WithPolicyRequirementsEnabled_ReturnsOrganizationAutoEnrollStatus_WithResetPasswordEnabledTrue(
+ User user,
+ Organization organization,
+ OrganizationUser organizationUser
+ )
+ {
+ var policyRequirement = new ResetPasswordPolicyRequirement() { AutoEnrollOrganizations = [organization.Id] };
+
+ _userService.GetUserByPrincipalAsync(Arg.Any()).Returns(user);
+ _organizationRepository.GetByIdentifierAsync(organization.Id.ToString()).Returns(organization);
+ _featureService.IsEnabled(FeatureFlagKeys.PolicyRequirements).Returns(true);
+ _organizationUserRepository.GetByOrganizationAsync(organization.Id, user.Id).Returns(organizationUser);
+ _policyRequirementQuery.GetAsync(user.Id).Returns(policyRequirement);
+
+ var result = await _sut.GetAutoEnrollStatus(organization.Id.ToString());
+
+ await _userService.Received(1).GetUserByPrincipalAsync(Arg.Any());
+ await _organizationRepository.Received(1).GetByIdentifierAsync(organization.Id.ToString());
+ await _policyRequirementQuery.Received(1).GetAsync(user.Id);
+
+ Assert.True(result.ResetPasswordEnabled);
+ Assert.Equal(result.Id, organization.Id);
+ }
+
+ [Theory, AutoData]
+ public async Task GetAutoEnrollStatus_WithPolicyRequirementsDisabled_ReturnsOrganizationAutoEnrollStatus_WithResetPasswordEnabledTrue(
+ User user,
+ Organization organization,
+ OrganizationUser organizationUser
+)
+ {
+
+ var policy = new Policy() { Type = PolicyType.ResetPassword, Enabled = true, Data = "{\"AutoEnrollEnabled\": true}", OrganizationId = organization.Id };
+
+ _userService.GetUserByPrincipalAsync(Arg.Any()).Returns(user);
+ _organizationRepository.GetByIdentifierAsync(organization.Id.ToString()).Returns(organization);
+ _featureService.IsEnabled(FeatureFlagKeys.PolicyRequirements).Returns(false);
+ _organizationUserRepository.GetByOrganizationAsync(organization.Id, user.Id).Returns(organizationUser);
+ _policyRepository.GetByOrganizationIdTypeAsync(organization.Id, PolicyType.ResetPassword).Returns(policy);
+
+ var result = await _sut.GetAutoEnrollStatus(organization.Id.ToString());
+
+ await _userService.Received(1).GetUserByPrincipalAsync(Arg.Any());
+ await _organizationRepository.Received(1).GetByIdentifierAsync(organization.Id.ToString());
+ await _policyRequirementQuery.Received(0).GetAsync(user.Id);
+ await _policyRepository.Received(1).GetByOrganizationIdTypeAsync(organization.Id, PolicyType.ResetPassword);
+
+ Assert.True(result.ResetPasswordEnabled);
+ }
}
diff --git a/test/Core.Test/AdminConsole/OrganizationFeatures/Policies/PolicyRequirements/ResetPasswordPolicyRequirementFactoryTests.cs b/test/Core.Test/AdminConsole/OrganizationFeatures/Policies/PolicyRequirements/ResetPasswordPolicyRequirementFactoryTests.cs
new file mode 100644
index 0000000000..181f4f170e
--- /dev/null
+++ b/test/Core.Test/AdminConsole/OrganizationFeatures/Policies/PolicyRequirements/ResetPasswordPolicyRequirementFactoryTests.cs
@@ -0,0 +1,37 @@
+using Bit.Core.AdminConsole.Enums;
+using Bit.Core.AdminConsole.Models.Data.Organizations.Policies;
+using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyRequirements;
+using Bit.Core.Test.AdminConsole.AutoFixture;
+using Bit.Test.Common.AutoFixture;
+using Bit.Test.Common.AutoFixture.Attributes;
+using Xunit;
+
+namespace Bit.Core.Test.AdminConsole.OrganizationFeatures.Policies.PolicyRequirements;
+
+[SutProviderCustomize]
+public class ResetPasswordPolicyRequirementFactoryTests
+{
+ [Theory, BitAutoData]
+ public void AutoEnroll_WithNoPolicies_IsEmpty(SutProvider sutProvider, Guid orgId)
+ {
+ var actual = sutProvider.Sut.Create([]);
+
+ Assert.False(actual.AutoEnrollEnabled(orgId));
+ }
+
+ [Theory, BitAutoData]
+ public void AutoEnrollAdministration_WithAnyResetPasswordPolices_ReturnsEnabledOrganizationIds(
+ [PolicyDetails(PolicyType.ResetPassword)] PolicyDetails[] policies,
+ SutProvider sutProvider)
+ {
+ policies[0].SetDataModel(new ResetPasswordDataModel { AutoEnrollEnabled = true });
+ policies[1].SetDataModel(new ResetPasswordDataModel { AutoEnrollEnabled = false });
+ policies[2].SetDataModel(new ResetPasswordDataModel { AutoEnrollEnabled = true });
+
+ var actual = sutProvider.Sut.Create(policies);
+
+ Assert.True(actual.AutoEnrollEnabled(policies[0].OrganizationId));
+ Assert.False(actual.AutoEnrollEnabled(policies[1].OrganizationId));
+ Assert.True(actual.AutoEnrollEnabled(policies[2].OrganizationId));
+ }
+}
From 7eb8ad8fa3a0d9975da0722874f777738d818cfe Mon Sep 17 00:00:00 2001
From: Github Actions
Date: Mon, 24 Mar 2025 10:49:33 +0000
Subject: [PATCH 109/184] Bumped version to 2025.3.4
---
Directory.Build.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index 2ede6ad8d1..0ef5513003 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -3,7 +3,7 @@
net8.0
- 2025.3.3
+ 2025.3.4
Bit.$(MSBuildProjectName)
enable
From 1db37a14abdb20a06ebe853de1aaa569782c1d13 Mon Sep 17 00:00:00 2001
From: Github Actions
Date: Mon, 24 Mar 2025 10:56:04 +0000
Subject: [PATCH 110/184] Bumped version to 2025.3.5
---
Directory.Build.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index 0ef5513003..0d17b69b55 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -3,7 +3,7 @@
net8.0
- 2025.3.4
+ 2025.3.5
Bit.$(MSBuildProjectName)
enable
From d345937ecca07aefd07f8cea421ae7ca2b6fcf98 Mon Sep 17 00:00:00 2001
From: Github Actions
Date: Mon, 24 Mar 2025 11:22:29 +0000
Subject: [PATCH 111/184] Bumped version to 2025.3.6
---
Directory.Build.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index 0d17b69b55..b9b8cf557a 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -3,7 +3,7 @@
net8.0
- 2025.3.5
+ 2025.3.6
Bit.$(MSBuildProjectName)
enable
From 24b63f2dcd12e1268fa625c8e1bef3e16c2aa17f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rui=20Tom=C3=A9?=
<108268980+r-tome@users.noreply.github.com>
Date: Mon, 24 Mar 2025 17:05:46 +0000
Subject: [PATCH 112/184] [PM-12493] Extract ConfirmUser methods from
OrganizationService into commands (#5505)
* Add ConfirmOrganizationUserCommand and IConfirmOrganizationUserCommand interface for managing organization user confirmations
* Add unit tests for ConfirmOrganizationUserCommand to validate user confirmation scenarios
* Register ConfirmOrganizationUserCommand for dependency injection
* Refactor OrganizationUsersController to utilize IConfirmOrganizationUserCommand for user confirmation processes
* Remove ConfirmUserAsync and ConfirmUsersAsync methods from IOrganizationService and OrganizationService
* Rename test methods in ConfirmOrganizationUserCommandTests for clarity and consistency
* Update test method name in ConfirmOrganizationUserCommandTests for improved clarity
---
.../OrganizationUsersController.cs | 11 +-
.../ConfirmOrganizationUserCommand.cs | 186 ++++++++++
.../IConfirmOrganizationUserCommand.cs | 30 ++
.../Services/IOrganizationService.cs | 3 -
.../Implementations/OrganizationService.cs | 126 -------
...OrganizationServiceCollectionExtensions.cs | 1 +
.../ConfirmOrganizationUserCommandTests.cs | 324 ++++++++++++++++++
.../Services/OrganizationServiceTests.cs | 301 ----------------
8 files changed, 548 insertions(+), 434 deletions(-)
create mode 100644 src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/ConfirmOrganizationUserCommand.cs
create mode 100644 src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/Interfaces/IConfirmOrganizationUserCommand.cs
create mode 100644 test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/ConfirmOrganizationUserCommandTests.cs
diff --git a/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs b/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs
index cc7f2314fd..cfe93e87ce 100644
--- a/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs
+++ b/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs
@@ -60,6 +60,7 @@ public class OrganizationUsersController : Controller
private readonly IPolicyRequirementQuery _policyRequirementQuery;
private readonly IFeatureService _featureService;
private readonly IPricingClient _pricingClient;
+ private readonly IConfirmOrganizationUserCommand _confirmOrganizationUserCommand;
public OrganizationUsersController(
IOrganizationRepository organizationRepository,
@@ -84,7 +85,8 @@ public class OrganizationUsersController : Controller
IGetOrganizationUsersManagementStatusQuery getOrganizationUsersManagementStatusQuery,
IPolicyRequirementQuery policyRequirementQuery,
IFeatureService featureService,
- IPricingClient pricingClient)
+ IPricingClient pricingClient,
+ IConfirmOrganizationUserCommand confirmOrganizationUserCommand)
{
_organizationRepository = organizationRepository;
_organizationUserRepository = organizationUserRepository;
@@ -109,6 +111,7 @@ public class OrganizationUsersController : Controller
_policyRequirementQuery = policyRequirementQuery;
_featureService = featureService;
_pricingClient = pricingClient;
+ _confirmOrganizationUserCommand = confirmOrganizationUserCommand;
}
[HttpGet("{id}")]
@@ -308,7 +311,7 @@ public class OrganizationUsersController : Controller
await _organizationService.InitPendingOrganization(user.Id, orgId, organizationUserId, model.Keys.PublicKey, model.Keys.EncryptedPrivateKey, model.CollectionName);
await _acceptOrgUserCommand.AcceptOrgUserByEmailTokenAsync(organizationUserId, user, model.Token, _userService);
- await _organizationService.ConfirmUserAsync(orgId, organizationUserId, model.Key, user.Id);
+ await _confirmOrganizationUserCommand.ConfirmUserAsync(orgId, organizationUserId, model.Key, user.Id);
}
[HttpPost("{organizationUserId}/accept")]
@@ -364,7 +367,7 @@ public class OrganizationUsersController : Controller
}
var userId = _userService.GetProperUserId(User);
- var result = await _organizationService.ConfirmUserAsync(orgGuidId, new Guid(id), model.Key, userId.Value);
+ var result = await _confirmOrganizationUserCommand.ConfirmUserAsync(orgGuidId, new Guid(id), model.Key, userId.Value);
}
[HttpPost("confirm")]
@@ -378,7 +381,7 @@ public class OrganizationUsersController : Controller
}
var userId = _userService.GetProperUserId(User);
- var results = await _organizationService.ConfirmUsersAsync(orgGuidId, model.ToDictionary(), userId.Value);
+ var results = await _confirmOrganizationUserCommand.ConfirmUsersAsync(orgGuidId, model.ToDictionary(), userId.Value);
return new ListResponseModel(results.Select(r =>
new OrganizationUserBulkResponseModel(r.Item1.Id, r.Item2)));
diff --git a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/ConfirmOrganizationUserCommand.cs b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/ConfirmOrganizationUserCommand.cs
new file mode 100644
index 0000000000..9bfe8f791e
--- /dev/null
+++ b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/ConfirmOrganizationUserCommand.cs
@@ -0,0 +1,186 @@
+using Bit.Core.AdminConsole.Enums;
+using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces;
+using Bit.Core.AdminConsole.Services;
+using Bit.Core.Auth.UserFeatures.TwoFactorAuth.Interfaces;
+using Bit.Core.Billing.Enums;
+using Bit.Core.Entities;
+using Bit.Core.Enums;
+using Bit.Core.Exceptions;
+using Bit.Core.Platform.Push;
+using Bit.Core.Repositories;
+using Bit.Core.Services;
+
+namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers;
+
+public class ConfirmOrganizationUserCommand : IConfirmOrganizationUserCommand
+{
+ private readonly IOrganizationRepository _organizationRepository;
+ private readonly IOrganizationUserRepository _organizationUserRepository;
+ private readonly IUserRepository _userRepository;
+ private readonly IEventService _eventService;
+ private readonly IMailService _mailService;
+ private readonly ITwoFactorIsEnabledQuery _twoFactorIsEnabledQuery;
+ private readonly IPushNotificationService _pushNotificationService;
+ private readonly IPushRegistrationService _pushRegistrationService;
+ private readonly IPolicyService _policyService;
+ private readonly IDeviceRepository _deviceRepository;
+
+ public ConfirmOrganizationUserCommand(
+ IOrganizationRepository organizationRepository,
+ IOrganizationUserRepository organizationUserRepository,
+ IUserRepository userRepository,
+ IEventService eventService,
+ IMailService mailService,
+ ITwoFactorIsEnabledQuery twoFactorIsEnabledQuery,
+ IPushNotificationService pushNotificationService,
+ IPushRegistrationService pushRegistrationService,
+ IPolicyService policyService,
+ IDeviceRepository deviceRepository)
+ {
+ _organizationRepository = organizationRepository;
+ _organizationUserRepository = organizationUserRepository;
+ _userRepository = userRepository;
+ _eventService = eventService;
+ _mailService = mailService;
+ _twoFactorIsEnabledQuery = twoFactorIsEnabledQuery;
+ _pushNotificationService = pushNotificationService;
+ _pushRegistrationService = pushRegistrationService;
+ _policyService = policyService;
+ _deviceRepository = deviceRepository;
+ }
+
+ public async Task ConfirmUserAsync(Guid organizationId, Guid organizationUserId, string key,
+ Guid confirmingUserId)
+ {
+ var result = await ConfirmUsersAsync(
+ organizationId,
+ new Dictionary() { { organizationUserId, key } },
+ confirmingUserId);
+
+ if (!result.Any())
+ {
+ throw new BadRequestException("User not valid.");
+ }
+
+ var (orgUser, error) = result[0];
+ if (error != "")
+ {
+ throw new BadRequestException(error);
+ }
+ return orgUser;
+ }
+
+ public async Task>> ConfirmUsersAsync(Guid organizationId, Dictionary keys,
+ Guid confirmingUserId)
+ {
+ var selectedOrganizationUsers = await _organizationUserRepository.GetManyAsync(keys.Keys);
+ var validSelectedOrganizationUsers = selectedOrganizationUsers
+ .Where(u => u.Status == OrganizationUserStatusType.Accepted && u.OrganizationId == organizationId && u.UserId != null)
+ .ToList();
+
+ if (!validSelectedOrganizationUsers.Any())
+ {
+ return new List>();
+ }
+
+ var validSelectedUserIds = validSelectedOrganizationUsers.Select(u => u.UserId.Value).ToList();
+
+ var organization = await _organizationRepository.GetByIdAsync(organizationId);
+ var allUsersOrgs = await _organizationUserRepository.GetManyByManyUsersAsync(validSelectedUserIds);
+ var users = await _userRepository.GetManyAsync(validSelectedUserIds);
+ var usersTwoFactorEnabled = await _twoFactorIsEnabledQuery.TwoFactorIsEnabledAsync(validSelectedUserIds);
+
+ var keyedFilteredUsers = validSelectedOrganizationUsers.ToDictionary(u => u.UserId.Value, u => u);
+ var keyedOrganizationUsers = allUsersOrgs.GroupBy(u => u.UserId.Value)
+ .ToDictionary(u => u.Key, u => u.ToList());
+
+ var succeededUsers = new List();
+ var result = new List>();
+
+ foreach (var user in users)
+ {
+ if (!keyedFilteredUsers.ContainsKey(user.Id))
+ {
+ continue;
+ }
+ var orgUser = keyedFilteredUsers[user.Id];
+ var orgUsers = keyedOrganizationUsers.GetValueOrDefault(user.Id, new List());
+ try
+ {
+ if (organization.PlanType == PlanType.Free && (orgUser.Type == OrganizationUserType.Admin
+ || orgUser.Type == OrganizationUserType.Owner))
+ {
+ // Since free organizations only supports a few users there is not much point in avoiding N+1 queries for this.
+ var adminCount = await _organizationUserRepository.GetCountByFreeOrganizationAdminUserAsync(user.Id);
+ if (adminCount > 0)
+ {
+ throw new BadRequestException("User can only be an admin of one free organization.");
+ }
+ }
+
+ var twoFactorEnabled = usersTwoFactorEnabled.FirstOrDefault(tuple => tuple.userId == user.Id).twoFactorIsEnabled;
+ await CheckPoliciesAsync(organizationId, user, orgUsers, twoFactorEnabled);
+ orgUser.Status = OrganizationUserStatusType.Confirmed;
+ orgUser.Key = keys[orgUser.Id];
+ orgUser.Email = null;
+
+ await _eventService.LogOrganizationUserEventAsync(orgUser, EventType.OrganizationUser_Confirmed);
+ await _mailService.SendOrganizationConfirmedEmailAsync(organization.DisplayName(), user.Email, orgUser.AccessSecretsManager);
+ await DeleteAndPushUserRegistrationAsync(organizationId, user.Id);
+ succeededUsers.Add(orgUser);
+ result.Add(Tuple.Create(orgUser, ""));
+ }
+ catch (BadRequestException e)
+ {
+ result.Add(Tuple.Create(orgUser, e.Message));
+ }
+ }
+
+ await _organizationUserRepository.ReplaceManyAsync(succeededUsers);
+
+ return result;
+ }
+
+ private async Task CheckPoliciesAsync(Guid organizationId, User user,
+ ICollection userOrgs, bool twoFactorEnabled)
+ {
+ // Enforce Two Factor Authentication Policy for this organization
+ var orgRequiresTwoFactor = (await _policyService.GetPoliciesApplicableToUserAsync(user.Id, PolicyType.TwoFactorAuthentication))
+ .Any(p => p.OrganizationId == organizationId);
+ if (orgRequiresTwoFactor && !twoFactorEnabled)
+ {
+ throw new BadRequestException("User does not have two-step login enabled.");
+ }
+
+ var hasOtherOrgs = userOrgs.Any(ou => ou.OrganizationId != organizationId);
+ var singleOrgPolicies = await _policyService.GetPoliciesApplicableToUserAsync(user.Id, PolicyType.SingleOrg);
+ var otherSingleOrgPolicies =
+ singleOrgPolicies.Where(p => p.OrganizationId != organizationId);
+ // Enforce Single Organization Policy for this organization
+ if (hasOtherOrgs && singleOrgPolicies.Any(p => p.OrganizationId == organizationId))
+ {
+ throw new BadRequestException("Cannot confirm this member to the organization until they leave or remove all other organizations.");
+ }
+ // Enforce Single Organization Policy of other organizations user is a member of
+ if (otherSingleOrgPolicies.Any())
+ {
+ throw new BadRequestException("Cannot confirm this member to the organization because they are in another organization which forbids it.");
+ }
+ }
+
+ private async Task DeleteAndPushUserRegistrationAsync(Guid organizationId, Guid userId)
+ {
+ var devices = await GetUserDeviceIdsAsync(userId);
+ await _pushRegistrationService.DeleteUserRegistrationOrganizationAsync(devices,
+ organizationId.ToString());
+ await _pushNotificationService.PushSyncOrgKeysAsync(userId);
+ }
+
+ private async Task> GetUserDeviceIdsAsync(Guid userId)
+ {
+ var devices = await _deviceRepository.GetManyByUserIdAsync(userId);
+ return devices
+ .Where(d => !string.IsNullOrWhiteSpace(d.PushToken))
+ .Select(d => d.Id.ToString());
+ }
+}
diff --git a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/Interfaces/IConfirmOrganizationUserCommand.cs b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/Interfaces/IConfirmOrganizationUserCommand.cs
new file mode 100644
index 0000000000..302ee0901d
--- /dev/null
+++ b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/Interfaces/IConfirmOrganizationUserCommand.cs
@@ -0,0 +1,30 @@
+using Bit.Core.Entities;
+
+namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces;
+
+///
+/// Command to confirm organization users who have accepted their invitations.
+///
+public interface IConfirmOrganizationUserCommand
+{
+ ///
+ /// Confirms a single organization user who has accepted their invitation.
+ ///
+ /// The ID of the organization.
+ /// The ID of the organization user to confirm.
+ /// The encrypted organization key for the user.
+ /// The ID of the user performing the confirmation.
+ /// The confirmed organization user.
+ /// Thrown when the user is not valid or cannot be confirmed.
+ Task ConfirmUserAsync(Guid organizationId, Guid organizationUserId, string key, Guid confirmingUserId);
+
+ ///
+ /// Confirms multiple organization users who have accepted their invitations.
+ ///
+ /// The ID of the organization.
+ /// A dictionary mapping organization user IDs to their encrypted organization keys.
+ /// The ID of the user performing the confirmation.
+ /// A list of tuples containing the organization user and an error message (if any).
+ Task>> ConfirmUsersAsync(Guid organizationId, Dictionary keys,
+ Guid confirmingUserId);
+}
diff --git a/src/Core/AdminConsole/Services/IOrganizationService.cs b/src/Core/AdminConsole/Services/IOrganizationService.cs
index dacb2ab162..476fccb480 100644
--- a/src/Core/AdminConsole/Services/IOrganizationService.cs
+++ b/src/Core/AdminConsole/Services/IOrganizationService.cs
@@ -38,9 +38,6 @@ public interface IOrganizationService
IEnumerable<(OrganizationUserInvite invite, string externalId)> invites);
Task>> ResendInvitesAsync(Guid organizationId, Guid? invitingUserId, IEnumerable organizationUsersId);
Task ResendInviteAsync(Guid organizationId, Guid? invitingUserId, Guid organizationUserId, bool initOrganization = false);
- Task ConfirmUserAsync(Guid organizationId, Guid organizationUserId, string key, Guid confirmingUserId);
- Task>> ConfirmUsersAsync(Guid organizationId, Dictionary keys,
- Guid confirmingUserId);
Task UpdateUserResetPasswordEnrollmentAsync(Guid organizationId, Guid userId, string resetPasswordKey, Guid? callingUserId);
Task ImportAsync(Guid organizationId, IEnumerable groups,
IEnumerable newUsers, IEnumerable removeUserExternalIds,
diff --git a/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs b/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs
index 772b407951..ab5703eaa1 100644
--- a/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs
+++ b/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs
@@ -1127,98 +1127,6 @@ public class OrganizationService : IOrganizationService
);
}
- public async Task ConfirmUserAsync(Guid organizationId, Guid organizationUserId, string key,
- Guid confirmingUserId)
- {
- var result = await ConfirmUsersAsync(
- organizationId,
- new Dictionary() { { organizationUserId, key } },
- confirmingUserId);
-
- if (!result.Any())
- {
- throw new BadRequestException("User not valid.");
- }
-
- var (orgUser, error) = result[0];
- if (error != "")
- {
- throw new BadRequestException(error);
- }
- return orgUser;
- }
-
- public async Task>> ConfirmUsersAsync(Guid organizationId, Dictionary keys,
- Guid confirmingUserId)
- {
- var selectedOrganizationUsers = await _organizationUserRepository.GetManyAsync(keys.Keys);
- var validSelectedOrganizationUsers = selectedOrganizationUsers
- .Where(u => u.Status == OrganizationUserStatusType.Accepted && u.OrganizationId == organizationId && u.UserId != null)
- .ToList();
-
- if (!validSelectedOrganizationUsers.Any())
- {
- return new List>();
- }
-
- var validSelectedUserIds = validSelectedOrganizationUsers.Select(u => u.UserId.Value).ToList();
-
- var organization = await GetOrgById(organizationId);
- var allUsersOrgs = await _organizationUserRepository.GetManyByManyUsersAsync(validSelectedUserIds);
- var users = await _userRepository.GetManyAsync(validSelectedUserIds);
- var usersTwoFactorEnabled = await _twoFactorIsEnabledQuery.TwoFactorIsEnabledAsync(validSelectedUserIds);
-
- var keyedFilteredUsers = validSelectedOrganizationUsers.ToDictionary(u => u.UserId.Value, u => u);
- var keyedOrganizationUsers = allUsersOrgs.GroupBy(u => u.UserId.Value)
- .ToDictionary(u => u.Key, u => u.ToList());
-
- var succeededUsers = new List();
- var result = new List>();
-
- foreach (var user in users)
- {
- if (!keyedFilteredUsers.ContainsKey(user.Id))
- {
- continue;
- }
- var orgUser = keyedFilteredUsers[user.Id];
- var orgUsers = keyedOrganizationUsers.GetValueOrDefault(user.Id, new List());
- try
- {
- if (organization.PlanType == PlanType.Free && (orgUser.Type == OrganizationUserType.Admin
- || orgUser.Type == OrganizationUserType.Owner))
- {
- // Since free organizations only supports a few users there is not much point in avoiding N+1 queries for this.
- var adminCount = await _organizationUserRepository.GetCountByFreeOrganizationAdminUserAsync(user.Id);
- if (adminCount > 0)
- {
- throw new BadRequestException("User can only be an admin of one free organization.");
- }
- }
-
- var twoFactorEnabled = usersTwoFactorEnabled.FirstOrDefault(tuple => tuple.userId == user.Id).twoFactorIsEnabled;
- await CheckPoliciesAsync(organizationId, user, orgUsers, twoFactorEnabled);
- orgUser.Status = OrganizationUserStatusType.Confirmed;
- orgUser.Key = keys[orgUser.Id];
- orgUser.Email = null;
-
- await _eventService.LogOrganizationUserEventAsync(orgUser, EventType.OrganizationUser_Confirmed);
- await _mailService.SendOrganizationConfirmedEmailAsync(organization.DisplayName(), user.Email, orgUser.AccessSecretsManager);
- await DeleteAndPushUserRegistrationAsync(organizationId, user.Id);
- succeededUsers.Add(orgUser);
- result.Add(Tuple.Create(orgUser, ""));
- }
- catch (BadRequestException e)
- {
- result.Add(Tuple.Create(orgUser, e.Message));
- }
- }
-
- await _organizationUserRepository.ReplaceManyAsync(succeededUsers);
-
- return result;
- }
-
internal async Task<(bool canScale, string failureReason)> CanScaleAsync(
Organization organization,
int seatsToAdd)
@@ -1305,32 +1213,7 @@ public class OrganizationService : IOrganizationService
}
}
- private async Task CheckPoliciesAsync(Guid organizationId, User user,
- ICollection userOrgs, bool twoFactorEnabled)
- {
- // Enforce Two Factor Authentication Policy for this organization
- var orgRequiresTwoFactor = (await _policyService.GetPoliciesApplicableToUserAsync(user.Id, PolicyType.TwoFactorAuthentication))
- .Any(p => p.OrganizationId == organizationId);
- if (orgRequiresTwoFactor && !twoFactorEnabled)
- {
- throw new BadRequestException("User does not have two-step login enabled.");
- }
- var hasOtherOrgs = userOrgs.Any(ou => ou.OrganizationId != organizationId);
- var singleOrgPolicies = await _policyService.GetPoliciesApplicableToUserAsync(user.Id, PolicyType.SingleOrg);
- var otherSingleOrgPolicies =
- singleOrgPolicies.Where(p => p.OrganizationId != organizationId);
- // Enforce Single Organization Policy for this organization
- if (hasOtherOrgs && singleOrgPolicies.Any(p => p.OrganizationId == organizationId))
- {
- throw new BadRequestException("Cannot confirm this member to the organization until they leave or remove all other organizations.");
- }
- // Enforce Single Organization Policy of other organizations user is a member of
- if (otherSingleOrgPolicies.Any())
- {
- throw new BadRequestException("Cannot confirm this member to the organization because they are in another organization which forbids it.");
- }
- }
public async Task UpdateUserResetPasswordEnrollmentAsync(Guid organizationId, Guid userId, string resetPasswordKey, Guid? callingUserId)
{
@@ -1640,15 +1523,6 @@ public class OrganizationService : IOrganizationService
await _groupRepository.UpdateUsersAsync(group.Id, users);
}
- private async Task DeleteAndPushUserRegistrationAsync(Guid organizationId, Guid userId)
- {
- var devices = await GetUserDeviceIdsAsync(userId);
- await _pushRegistrationService.DeleteUserRegistrationOrganizationAsync(devices,
- organizationId.ToString());
- await _pushNotificationService.PushSyncOrgKeysAsync(userId);
- }
-
-
private async Task> GetUserDeviceIdsAsync(Guid userId)
{
var devices = await _deviceRepository.GetManyByUserIdAsync(userId);
diff --git a/src/Core/OrganizationFeatures/OrganizationServiceCollectionExtensions.cs b/src/Core/OrganizationFeatures/OrganizationServiceCollectionExtensions.cs
index 232e04fbd0..e13a06f660 100644
--- a/src/Core/OrganizationFeatures/OrganizationServiceCollectionExtensions.cs
+++ b/src/Core/OrganizationFeatures/OrganizationServiceCollectionExtensions.cs
@@ -116,6 +116,7 @@ public static class OrganizationServiceCollectionExtensions
services.AddScoped();
services.AddScoped();
services.AddScoped();
+ services.AddScoped();
}
private static void AddOrganizationApiKeyCommandsQueries(this IServiceCollection services)
diff --git a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/ConfirmOrganizationUserCommandTests.cs b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/ConfirmOrganizationUserCommandTests.cs
new file mode 100644
index 0000000000..06335f668d
--- /dev/null
+++ b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/ConfirmOrganizationUserCommandTests.cs
@@ -0,0 +1,324 @@
+using Bit.Core.AdminConsole.Entities;
+using Bit.Core.AdminConsole.Enums;
+using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers;
+using Bit.Core.AdminConsole.Services;
+using Bit.Core.Auth.UserFeatures.TwoFactorAuth.Interfaces;
+using Bit.Core.Billing.Enums;
+using Bit.Core.Entities;
+using Bit.Core.Enums;
+using Bit.Core.Exceptions;
+using Bit.Core.Models.Data.Organizations.OrganizationUsers;
+using Bit.Core.Repositories;
+using Bit.Core.Services;
+using Bit.Core.Test.AdminConsole.AutoFixture;
+using Bit.Core.Test.AutoFixture.OrganizationUserFixtures;
+using Bit.Test.Common.AutoFixture;
+using Bit.Test.Common.AutoFixture.Attributes;
+using NSubstitute;
+using Xunit;
+
+namespace Bit.Core.Test.AdminConsole.OrganizationFeatures.OrganizationUsers;
+
+[SutProviderCustomize]
+public class ConfirmOrganizationUserCommandTests
+{
+ [Theory, BitAutoData]
+ public async Task ConfirmUserAsync_WithInvalidStatus_ThrowsBadRequestException(OrganizationUser confirmingUser,
+ [OrganizationUser(OrganizationUserStatusType.Invited)] OrganizationUser orgUser, string key,
+ SutProvider sutProvider)
+ {
+ var organizationUserRepository = sutProvider.GetDependency();
+
+ organizationUserRepository.GetByIdAsync(orgUser.Id).Returns(orgUser);
+
+ var exception = await Assert.ThrowsAsync(
+ () => sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id));
+ Assert.Contains("User not valid.", exception.Message);
+ }
+
+ [Theory, BitAutoData]
+ public async Task ConfirmUserAsync_WithWrongOrganization_ThrowsBadRequestException(OrganizationUser confirmingUser,
+ [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, string key,
+ SutProvider sutProvider)
+ {
+ var organizationUserRepository = sutProvider.GetDependency();
+
+ organizationUserRepository.GetByIdAsync(orgUser.Id).Returns(orgUser);
+
+ var exception = await Assert.ThrowsAsync(
+ () => sutProvider.Sut.ConfirmUserAsync(confirmingUser.OrganizationId, orgUser.Id, key, confirmingUser.Id));
+ Assert.Contains("User not valid.", exception.Message);
+ }
+
+ [Theory]
+ [BitAutoData(OrganizationUserType.Admin)]
+ [BitAutoData(OrganizationUserType.Owner)]
+ public async Task ConfirmUserAsync_ToFree_WithExistingAdminOrOwner_ThrowsBadRequestException(OrganizationUserType userType, Organization org, OrganizationUser confirmingUser,
+ [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
+ string key, SutProvider sutProvider)
+ {
+ var organizationUserRepository = sutProvider.GetDependency();
+ var organizationRepository = sutProvider.GetDependency();
+ var userRepository = sutProvider.GetDependency();
+
+ org.PlanType = PlanType.Free;
+ orgUser.OrganizationId = confirmingUser.OrganizationId = org.Id;
+ orgUser.UserId = user.Id;
+ orgUser.Type = userType;
+ organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
+ organizationUserRepository.GetCountByFreeOrganizationAdminUserAsync(orgUser.UserId.Value).Returns(1);
+ organizationRepository.GetByIdAsync(org.Id).Returns(org);
+ userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
+
+ var exception = await Assert.ThrowsAsync(
+ () => sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id));
+ Assert.Contains("User can only be an admin of one free organization.", exception.Message);
+ }
+
+ [Theory]
+ [BitAutoData(PlanType.Custom, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.Custom, OrganizationUserType.Owner)]
+ [BitAutoData(PlanType.EnterpriseAnnually, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.EnterpriseAnnually, OrganizationUserType.Owner)]
+ [BitAutoData(PlanType.EnterpriseAnnually2020, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.EnterpriseAnnually2020, OrganizationUserType.Owner)]
+ [BitAutoData(PlanType.EnterpriseAnnually2019, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.EnterpriseAnnually2019, OrganizationUserType.Owner)]
+ [BitAutoData(PlanType.EnterpriseMonthly, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.EnterpriseMonthly, OrganizationUserType.Owner)]
+ [BitAutoData(PlanType.EnterpriseMonthly2020, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.EnterpriseMonthly2020, OrganizationUserType.Owner)]
+ [BitAutoData(PlanType.EnterpriseMonthly2019, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.EnterpriseMonthly2019, OrganizationUserType.Owner)]
+ [BitAutoData(PlanType.FamiliesAnnually, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.FamiliesAnnually, OrganizationUserType.Owner)]
+ [BitAutoData(PlanType.FamiliesAnnually2019, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.FamiliesAnnually2019, OrganizationUserType.Owner)]
+ [BitAutoData(PlanType.TeamsAnnually, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.TeamsAnnually, OrganizationUserType.Owner)]
+ [BitAutoData(PlanType.TeamsAnnually2020, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.TeamsAnnually2020, OrganizationUserType.Owner)]
+ [BitAutoData(PlanType.TeamsAnnually2019, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.TeamsAnnually2019, OrganizationUserType.Owner)]
+ [BitAutoData(PlanType.TeamsMonthly, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.TeamsMonthly, OrganizationUserType.Owner)]
+ [BitAutoData(PlanType.TeamsMonthly2020, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.TeamsMonthly2020, OrganizationUserType.Owner)]
+ [BitAutoData(PlanType.TeamsMonthly2019, OrganizationUserType.Admin)]
+ [BitAutoData(PlanType.TeamsMonthly2019, OrganizationUserType.Owner)]
+ public async Task ConfirmUserAsync_ToNonFree_WithExistingFreeAdminOrOwner_Succeeds(PlanType planType, OrganizationUserType orgUserType, Organization org, OrganizationUser confirmingUser,
+ [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
+ string key, SutProvider sutProvider)
+ {
+ var organizationUserRepository = sutProvider.GetDependency();
+ var organizationRepository = sutProvider.GetDependency();
+ var userRepository = sutProvider.GetDependency();
+
+ org.PlanType = planType;
+ orgUser.OrganizationId = confirmingUser.OrganizationId = org.Id;
+ orgUser.UserId = user.Id;
+ orgUser.Type = orgUserType;
+ orgUser.AccessSecretsManager = false;
+ organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
+ organizationUserRepository.GetCountByFreeOrganizationAdminUserAsync(orgUser.UserId.Value).Returns(1);
+ organizationRepository.GetByIdAsync(org.Id).Returns(org);
+ userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
+
+ await sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id);
+
+ await sutProvider.GetDependency().Received(1).LogOrganizationUserEventAsync(orgUser, EventType.OrganizationUser_Confirmed);
+ await sutProvider.GetDependency().Received(1).SendOrganizationConfirmedEmailAsync(org.DisplayName(), user.Email);
+ await organizationUserRepository.Received(1).ReplaceManyAsync(Arg.Is>(users => users.Contains(orgUser) && users.Count == 1));
+ }
+
+
+ [Theory, BitAutoData]
+ public async Task ConfirmUserAsync_AsUser_WithSingleOrgPolicyAppliedFromConfirmingOrg_ThrowsBadRequestException(Organization org, OrganizationUser confirmingUser,
+ [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
+ OrganizationUser orgUserAnotherOrg, [OrganizationUserPolicyDetails(PolicyType.SingleOrg)] OrganizationUserPolicyDetails singleOrgPolicy,
+ string key, SutProvider sutProvider)
+ {
+ var organizationUserRepository = sutProvider.GetDependency();
+ var organizationRepository = sutProvider.GetDependency();
+ var userRepository = sutProvider.GetDependency();
+ var policyService = sutProvider.GetDependency();
+
+ org.PlanType = PlanType.EnterpriseAnnually;
+ orgUser.Status = OrganizationUserStatusType.Accepted;
+ orgUser.OrganizationId = confirmingUser.OrganizationId = org.Id;
+ orgUser.UserId = orgUserAnotherOrg.UserId = user.Id;
+ organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
+ organizationUserRepository.GetManyByManyUsersAsync(default).ReturnsForAnyArgs(new[] { orgUserAnotherOrg });
+ organizationRepository.GetByIdAsync(org.Id).Returns(org);
+ userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
+ singleOrgPolicy.OrganizationId = org.Id;
+ policyService.GetPoliciesApplicableToUserAsync(user.Id, PolicyType.SingleOrg).Returns(new[] { singleOrgPolicy });
+
+ var exception = await Assert.ThrowsAsync(
+ () => sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id));
+ Assert.Contains("Cannot confirm this member to the organization until they leave or remove all other organizations.", exception.Message);
+ }
+
+ [Theory, BitAutoData]
+ public async Task ConfirmUserAsync_AsUser_WithSingleOrgPolicyAppliedFromOtherOrg_ThrowsBadRequestException(Organization org, OrganizationUser confirmingUser,
+ [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
+ OrganizationUser orgUserAnotherOrg, [OrganizationUserPolicyDetails(PolicyType.SingleOrg)] OrganizationUserPolicyDetails singleOrgPolicy,
+ string key, SutProvider sutProvider)
+ {
+ var organizationUserRepository = sutProvider.GetDependency();
+ var organizationRepository = sutProvider.GetDependency();
+ var userRepository = sutProvider.GetDependency();
+ var policyService = sutProvider.GetDependency();
+
+ org.PlanType = PlanType.EnterpriseAnnually;
+ orgUser.Status = OrganizationUserStatusType.Accepted;
+ orgUser.OrganizationId = confirmingUser.OrganizationId = org.Id;
+ orgUser.UserId = orgUserAnotherOrg.UserId = user.Id;
+ organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
+ organizationUserRepository.GetManyByManyUsersAsync(default).ReturnsForAnyArgs(new[] { orgUserAnotherOrg });
+ organizationRepository.GetByIdAsync(org.Id).Returns(org);
+ userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
+ singleOrgPolicy.OrganizationId = orgUserAnotherOrg.Id;
+ policyService.GetPoliciesApplicableToUserAsync(user.Id, PolicyType.SingleOrg).Returns(new[] { singleOrgPolicy });
+
+ var exception = await Assert.ThrowsAsync(
+ () => sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id));
+ Assert.Contains("Cannot confirm this member to the organization because they are in another organization which forbids it.", exception.Message);
+ }
+
+ [Theory]
+ [BitAutoData(OrganizationUserType.Admin)]
+ [BitAutoData(OrganizationUserType.Owner)]
+ public async Task ConfirmUserAsync_AsOwnerOrAdmin_WithSingleOrgPolicy_ExcludedViaUserType_Success(
+ OrganizationUserType userType, Organization org, OrganizationUser confirmingUser,
+ [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
+ OrganizationUser orgUserAnotherOrg,
+ string key, SutProvider sutProvider)
+ {
+ var organizationUserRepository = sutProvider.GetDependency();
+ var organizationRepository = sutProvider.GetDependency();
+ var userRepository = sutProvider.GetDependency();
+
+ org.PlanType = PlanType.EnterpriseAnnually;
+ orgUser.Type = userType;
+ orgUser.Status = OrganizationUserStatusType.Accepted;
+ orgUser.OrganizationId = confirmingUser.OrganizationId = org.Id;
+ orgUser.UserId = orgUserAnotherOrg.UserId = user.Id;
+ orgUser.AccessSecretsManager = true;
+ organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
+ organizationUserRepository.GetManyByManyUsersAsync(default).ReturnsForAnyArgs(new[] { orgUserAnotherOrg });
+ organizationRepository.GetByIdAsync(org.Id).Returns(org);
+ userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
+
+ await sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id);
+
+ await sutProvider.GetDependency().Received(1).LogOrganizationUserEventAsync(orgUser, EventType.OrganizationUser_Confirmed);
+ await sutProvider.GetDependency().Received(1).SendOrganizationConfirmedEmailAsync(org.DisplayName(), user.Email, true);
+ await organizationUserRepository.Received(1).ReplaceManyAsync(Arg.Is>(users => users.Contains(orgUser) && users.Count == 1));
+ }
+
+ [Theory, BitAutoData]
+ public async Task ConfirmUserAsync_WithTwoFactorPolicyAndTwoFactorDisabled_ThrowsBadRequestException(Organization org, OrganizationUser confirmingUser,
+ [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
+ OrganizationUser orgUserAnotherOrg,
+ [OrganizationUserPolicyDetails(PolicyType.TwoFactorAuthentication)] OrganizationUserPolicyDetails twoFactorPolicy,
+ string key, SutProvider sutProvider)
+ {
+ var organizationUserRepository = sutProvider.GetDependency();
+ var organizationRepository = sutProvider.GetDependency();
+ var userRepository = sutProvider.GetDependency();
+ var policyService = sutProvider.GetDependency();
+ var twoFactorIsEnabledQuery = sutProvider.GetDependency();
+
+ org.PlanType = PlanType.EnterpriseAnnually;
+ orgUser.OrganizationId = confirmingUser.OrganizationId = org.Id;
+ orgUser.UserId = orgUserAnotherOrg.UserId = user.Id;
+ organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
+ organizationUserRepository.GetManyByManyUsersAsync(default).ReturnsForAnyArgs(new[] { orgUserAnotherOrg });
+ organizationRepository.GetByIdAsync(org.Id).Returns(org);
+ userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
+ twoFactorPolicy.OrganizationId = org.Id;
+ policyService.GetPoliciesApplicableToUserAsync(user.Id, PolicyType.TwoFactorAuthentication).Returns(new[] { twoFactorPolicy });
+ twoFactorIsEnabledQuery.TwoFactorIsEnabledAsync(Arg.Is>(ids => ids.Contains(user.Id)))
+ .Returns(new List<(Guid userId, bool twoFactorIsEnabled)>() { (user.Id, false) });
+
+ var exception = await Assert.ThrowsAsync(
+ () => sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id));
+ Assert.Contains("User does not have two-step login enabled.", exception.Message);
+ }
+
+ [Theory, BitAutoData]
+ public async Task ConfirmUserAsync_WithTwoFactorPolicyAndTwoFactorEnabled_Succeeds(Organization org, OrganizationUser confirmingUser,
+ [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
+ [OrganizationUserPolicyDetails(PolicyType.TwoFactorAuthentication)] OrganizationUserPolicyDetails twoFactorPolicy,
+ string key, SutProvider sutProvider)
+ {
+ var organizationUserRepository = sutProvider.GetDependency();
+ var organizationRepository = sutProvider.GetDependency();
+ var userRepository = sutProvider.GetDependency();
+ var policyService = sutProvider.GetDependency();
+ var twoFactorIsEnabledQuery = sutProvider.GetDependency();
+
+ org.PlanType = PlanType.EnterpriseAnnually;
+ orgUser.OrganizationId = confirmingUser.OrganizationId = org.Id;
+ orgUser.UserId = user.Id;
+ organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
+ organizationRepository.GetByIdAsync(org.Id).Returns(org);
+ userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
+ twoFactorPolicy.OrganizationId = org.Id;
+ policyService.GetPoliciesApplicableToUserAsync(user.Id, PolicyType.TwoFactorAuthentication).Returns(new[] { twoFactorPolicy });
+ twoFactorIsEnabledQuery.TwoFactorIsEnabledAsync(Arg.Is>(ids => ids.Contains(user.Id)))
+ .Returns(new List<(Guid userId, bool twoFactorIsEnabled)>() { (user.Id, true) });
+
+ await sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id);
+ }
+
+ [Theory, BitAutoData]
+ public async Task ConfirmUsersAsync_WithMultipleUsers_ReturnsExpectedMixedResults(Organization org,
+ OrganizationUser confirmingUser,
+ [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser1,
+ [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser2,
+ [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser3,
+ OrganizationUser anotherOrgUser, User user1, User user2, User user3,
+ [OrganizationUserPolicyDetails(PolicyType.TwoFactorAuthentication)] OrganizationUserPolicyDetails twoFactorPolicy,
+ [OrganizationUserPolicyDetails(PolicyType.SingleOrg)] OrganizationUserPolicyDetails singleOrgPolicy,
+ string key, SutProvider sutProvider)
+ {
+ var organizationUserRepository = sutProvider.GetDependency();
+ var organizationRepository = sutProvider.GetDependency();
+ var userRepository = sutProvider.GetDependency();
+ var policyService = sutProvider.GetDependency();
+ var twoFactorIsEnabledQuery = sutProvider.GetDependency();
+
+ org.PlanType = PlanType.EnterpriseAnnually;
+ orgUser1.OrganizationId = orgUser2.OrganizationId = orgUser3.OrganizationId = confirmingUser.OrganizationId = org.Id;
+ orgUser1.UserId = user1.Id;
+ orgUser2.UserId = user2.Id;
+ orgUser3.UserId = user3.Id;
+ anotherOrgUser.UserId = user3.Id;
+ var orgUsers = new[] { orgUser1, orgUser2, orgUser3 };
+ organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(orgUsers);
+ organizationRepository.GetByIdAsync(org.Id).Returns(org);
+ userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user1, user2, user3 });
+ twoFactorPolicy.OrganizationId = org.Id;
+ policyService.GetPoliciesApplicableToUserAsync(Arg.Any(), PolicyType.TwoFactorAuthentication).Returns(new[] { twoFactorPolicy });
+ twoFactorIsEnabledQuery.TwoFactorIsEnabledAsync(Arg.Is>(ids => ids.Contains(user1.Id) && ids.Contains(user2.Id) && ids.Contains(user3.Id)))
+ .Returns(new List<(Guid userId, bool twoFactorIsEnabled)>()
+ {
+ (user1.Id, true),
+ (user2.Id, false),
+ (user3.Id, true)
+ });
+ singleOrgPolicy.OrganizationId = org.Id;
+ policyService.GetPoliciesApplicableToUserAsync(user3.Id, PolicyType.SingleOrg)
+ .Returns(new[] { singleOrgPolicy });
+ organizationUserRepository.GetManyByManyUsersAsync(default)
+ .ReturnsForAnyArgs(new[] { orgUser1, orgUser2, orgUser3, anotherOrgUser });
+
+ var keys = orgUsers.ToDictionary(ou => ou.Id, _ => key);
+ var result = await sutProvider.Sut.ConfirmUsersAsync(confirmingUser.OrganizationId, keys, confirmingUser.Id);
+ Assert.Contains("", result[0].Item2);
+ Assert.Contains("User does not have two-step login enabled.", result[1].Item2);
+ Assert.Contains("Cannot confirm this member to the organization until they leave or remove all other organizations.", result[2].Item2);
+ }
+}
diff --git a/test/Core.Test/AdminConsole/Services/OrganizationServiceTests.cs b/test/Core.Test/AdminConsole/Services/OrganizationServiceTests.cs
index 4c42fdfeb9..82dc0e2ebe 100644
--- a/test/Core.Test/AdminConsole/Services/OrganizationServiceTests.cs
+++ b/test/Core.Test/AdminConsole/Services/OrganizationServiceTests.cs
@@ -24,7 +24,6 @@ using Bit.Core.Platform.Push;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings;
-using Bit.Core.Test.AdminConsole.AutoFixture;
using Bit.Core.Test.AutoFixture.OrganizationFixtures;
using Bit.Core.Test.AutoFixture.OrganizationUserFixtures;
using Bit.Core.Tokens;
@@ -978,306 +977,6 @@ OrganizationUserInvite invite, SutProvider sutProvider)
sutProvider.GetDependency().ManageUsers(organization.Id).Returns(true);
}
- [Theory, BitAutoData]
- public async Task ConfirmUser_InvalidStatus(OrganizationUser confirmingUser,
- [OrganizationUser(OrganizationUserStatusType.Invited)] OrganizationUser orgUser, string key,
- SutProvider sutProvider)
- {
- var organizationUserRepository = sutProvider.GetDependency();
-
- organizationUserRepository.GetByIdAsync(orgUser.Id).Returns(orgUser);
-
- var exception = await Assert.ThrowsAsync(
- () => sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id));
- Assert.Contains("User not valid.", exception.Message);
- }
-
- [Theory, BitAutoData]
- public async Task ConfirmUser_WrongOrganization(OrganizationUser confirmingUser,
- [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, string key,
- SutProvider sutProvider)
- {
- var organizationUserRepository = sutProvider.GetDependency();
-
- organizationUserRepository.GetByIdAsync(orgUser.Id).Returns(orgUser);
-
- var exception = await Assert.ThrowsAsync(
- () => sutProvider.Sut.ConfirmUserAsync(confirmingUser.OrganizationId, orgUser.Id, key, confirmingUser.Id));
- Assert.Contains("User not valid.", exception.Message);
- }
-
- [Theory]
- [BitAutoData(OrganizationUserType.Admin)]
- [BitAutoData(OrganizationUserType.Owner)]
- public async Task ConfirmUserToFree_AlreadyFreeAdminOrOwner_Throws(OrganizationUserType userType, Organization org, OrganizationUser confirmingUser,
- [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
- string key, SutProvider sutProvider)
- {
- var organizationUserRepository = sutProvider.GetDependency();
- var organizationRepository = sutProvider.GetDependency();
- var userRepository = sutProvider.GetDependency();
-
- org.PlanType = PlanType.Free;
- orgUser.OrganizationId = confirmingUser.OrganizationId = org.Id;
- orgUser.UserId = user.Id;
- orgUser.Type = userType;
- organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
- organizationUserRepository.GetCountByFreeOrganizationAdminUserAsync(orgUser.UserId.Value).Returns(1);
- organizationRepository.GetByIdAsync(org.Id).Returns(org);
- userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
-
- var exception = await Assert.ThrowsAsync(
- () => sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id));
- Assert.Contains("User can only be an admin of one free organization.", exception.Message);
- }
-
- [Theory]
- [BitAutoData(PlanType.Custom, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.Custom, OrganizationUserType.Owner)]
- [BitAutoData(PlanType.EnterpriseAnnually, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.EnterpriseAnnually, OrganizationUserType.Owner)]
- [BitAutoData(PlanType.EnterpriseAnnually2020, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.EnterpriseAnnually2020, OrganizationUserType.Owner)]
- [BitAutoData(PlanType.EnterpriseAnnually2019, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.EnterpriseAnnually2019, OrganizationUserType.Owner)]
- [BitAutoData(PlanType.EnterpriseMonthly, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.EnterpriseMonthly, OrganizationUserType.Owner)]
- [BitAutoData(PlanType.EnterpriseMonthly2020, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.EnterpriseMonthly2020, OrganizationUserType.Owner)]
- [BitAutoData(PlanType.EnterpriseMonthly2019, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.EnterpriseMonthly2019, OrganizationUserType.Owner)]
- [BitAutoData(PlanType.FamiliesAnnually, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.FamiliesAnnually, OrganizationUserType.Owner)]
- [BitAutoData(PlanType.FamiliesAnnually2019, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.FamiliesAnnually2019, OrganizationUserType.Owner)]
- [BitAutoData(PlanType.TeamsAnnually, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.TeamsAnnually, OrganizationUserType.Owner)]
- [BitAutoData(PlanType.TeamsAnnually2020, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.TeamsAnnually2020, OrganizationUserType.Owner)]
- [BitAutoData(PlanType.TeamsAnnually2019, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.TeamsAnnually2019, OrganizationUserType.Owner)]
- [BitAutoData(PlanType.TeamsMonthly, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.TeamsMonthly, OrganizationUserType.Owner)]
- [BitAutoData(PlanType.TeamsMonthly2020, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.TeamsMonthly2020, OrganizationUserType.Owner)]
- [BitAutoData(PlanType.TeamsMonthly2019, OrganizationUserType.Admin)]
- [BitAutoData(PlanType.TeamsMonthly2019, OrganizationUserType.Owner)]
- public async Task ConfirmUserToNonFree_AlreadyFreeAdminOrOwner_DoesNotThrow(PlanType planType, OrganizationUserType orgUserType, Organization org, OrganizationUser confirmingUser,
- [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
- string key, SutProvider sutProvider)
- {
- var organizationUserRepository = sutProvider.GetDependency();
- var organizationRepository = sutProvider.GetDependency();
- var userRepository = sutProvider.GetDependency();
-
- org.PlanType = planType;
- orgUser.OrganizationId = confirmingUser.OrganizationId = org.Id;
- orgUser.UserId = user.Id;
- orgUser.Type = orgUserType;
- orgUser.AccessSecretsManager = false;
- organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
- organizationUserRepository.GetCountByFreeOrganizationAdminUserAsync(orgUser.UserId.Value).Returns(1);
- organizationRepository.GetByIdAsync(org.Id).Returns(org);
- userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
-
- await sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id);
-
- await sutProvider.GetDependency().Received(1).LogOrganizationUserEventAsync(orgUser, EventType.OrganizationUser_Confirmed);
- await sutProvider.GetDependency().Received(1).SendOrganizationConfirmedEmailAsync(org.DisplayName(), user.Email);
- await organizationUserRepository.Received(1).ReplaceManyAsync(Arg.Is>(users => users.Contains(orgUser) && users.Count == 1));
- }
-
-
- [Theory, BitAutoData]
- public async Task ConfirmUser_AsUser_SingleOrgPolicy_AppliedFromConfirmingOrg_Throws(Organization org, OrganizationUser confirmingUser,
- [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
- OrganizationUser orgUserAnotherOrg, [OrganizationUserPolicyDetails(PolicyType.SingleOrg)] OrganizationUserPolicyDetails singleOrgPolicy,
- string key, SutProvider sutProvider)
- {
- var organizationUserRepository = sutProvider.GetDependency();
- var organizationRepository = sutProvider.GetDependency();
- var userRepository = sutProvider.GetDependency();
- var policyService = sutProvider.GetDependency();
-
- org.PlanType = PlanType.EnterpriseAnnually;
- orgUser.Status = OrganizationUserStatusType.Accepted;
- orgUser.OrganizationId = confirmingUser.OrganizationId = org.Id;
- orgUser.UserId = orgUserAnotherOrg.UserId = user.Id;
- organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
- organizationUserRepository.GetManyByManyUsersAsync(default).ReturnsForAnyArgs(new[] { orgUserAnotherOrg });
- organizationRepository.GetByIdAsync(org.Id).Returns(org);
- userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
- singleOrgPolicy.OrganizationId = org.Id;
- policyService.GetPoliciesApplicableToUserAsync(user.Id, PolicyType.SingleOrg).Returns(new[] { singleOrgPolicy });
-
- var exception = await Assert.ThrowsAsync(
- () => sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id));
- Assert.Contains("Cannot confirm this member to the organization until they leave or remove all other organizations.", exception.Message);
- }
-
- [Theory, BitAutoData]
- public async Task ConfirmUser_AsUser_SingleOrgPolicy_AppliedFromOtherOrg_Throws(Organization org, OrganizationUser confirmingUser,
- [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
- OrganizationUser orgUserAnotherOrg, [OrganizationUserPolicyDetails(PolicyType.SingleOrg)] OrganizationUserPolicyDetails singleOrgPolicy,
- string key, SutProvider sutProvider)
- {
- var organizationUserRepository = sutProvider.GetDependency();
- var organizationRepository = sutProvider.GetDependency();
- var userRepository = sutProvider.GetDependency();
- var policyService = sutProvider.GetDependency();
-
- org.PlanType = PlanType.EnterpriseAnnually;
- orgUser.Status = OrganizationUserStatusType.Accepted;
- orgUser.OrganizationId = confirmingUser.OrganizationId = org.Id;
- orgUser.UserId = orgUserAnotherOrg.UserId = user.Id;
- organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
- organizationUserRepository.GetManyByManyUsersAsync(default).ReturnsForAnyArgs(new[] { orgUserAnotherOrg });
- organizationRepository.GetByIdAsync(org.Id).Returns(org);
- userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
- singleOrgPolicy.OrganizationId = orgUserAnotherOrg.Id;
- policyService.GetPoliciesApplicableToUserAsync(user.Id, PolicyType.SingleOrg).Returns(new[] { singleOrgPolicy });
-
- var exception = await Assert.ThrowsAsync(
- () => sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id));
- Assert.Contains("Cannot confirm this member to the organization because they are in another organization which forbids it.", exception.Message);
- }
-
- [Theory]
- [BitAutoData(OrganizationUserType.Admin)]
- [BitAutoData(OrganizationUserType.Owner)]
- public async Task ConfirmUser_AsOwnerOrAdmin_SingleOrgPolicy_ExcludedViaUserType_Success(
- OrganizationUserType userType, Organization org, OrganizationUser confirmingUser,
- [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
- OrganizationUser orgUserAnotherOrg,
- string key, SutProvider sutProvider)
- {
- var organizationUserRepository = sutProvider.GetDependency();
- var organizationRepository = sutProvider.GetDependency();
- var userRepository = sutProvider.GetDependency();
-
- org.PlanType = PlanType.EnterpriseAnnually;
- orgUser.Type = userType;
- orgUser.Status = OrganizationUserStatusType.Accepted;
- orgUser.OrganizationId = confirmingUser.OrganizationId = org.Id;
- orgUser.UserId = orgUserAnotherOrg.UserId = user.Id;
- orgUser.AccessSecretsManager = true;
- organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
- organizationUserRepository.GetManyByManyUsersAsync(default).ReturnsForAnyArgs(new[] { orgUserAnotherOrg });
- organizationRepository.GetByIdAsync(org.Id).Returns(org);
- userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
-
- await sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id);
-
- await sutProvider.GetDependency().Received(1).LogOrganizationUserEventAsync(orgUser, EventType.OrganizationUser_Confirmed);
- await sutProvider.GetDependency().Received(1).SendOrganizationConfirmedEmailAsync(org.DisplayName(), user.Email, true);
- await organizationUserRepository.Received(1).ReplaceManyAsync(Arg.Is>(users => users.Contains(orgUser) && users.Count == 1));
- }
-
- [Theory, BitAutoData]
- public async Task ConfirmUser_TwoFactorPolicy_NotEnabled_Throws(Organization org, OrganizationUser confirmingUser,
- [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
- OrganizationUser orgUserAnotherOrg,
- [OrganizationUserPolicyDetails(PolicyType.TwoFactorAuthentication)] OrganizationUserPolicyDetails twoFactorPolicy,
- string key, SutProvider sutProvider)
- {
- var organizationUserRepository = sutProvider.GetDependency();
- var organizationRepository = sutProvider.GetDependency();
- var userRepository = sutProvider.GetDependency();
- var policyService = sutProvider.GetDependency();
- var twoFactorIsEnabledQuery = sutProvider.GetDependency();
-
- org.PlanType = PlanType.EnterpriseAnnually;
- orgUser.OrganizationId = confirmingUser.OrganizationId = org.Id;
- orgUser.UserId = orgUserAnotherOrg.UserId = user.Id;
- organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
- organizationUserRepository.GetManyByManyUsersAsync(default).ReturnsForAnyArgs(new[] { orgUserAnotherOrg });
- organizationRepository.GetByIdAsync(org.Id).Returns(org);
- userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
- twoFactorPolicy.OrganizationId = org.Id;
- policyService.GetPoliciesApplicableToUserAsync(user.Id, PolicyType.TwoFactorAuthentication).Returns(new[] { twoFactorPolicy });
- twoFactorIsEnabledQuery.TwoFactorIsEnabledAsync(Arg.Is>(ids => ids.Contains(user.Id)))
- .Returns(new List<(Guid userId, bool twoFactorIsEnabled)>() { (user.Id, false) });
-
- var exception = await Assert.ThrowsAsync(
- () => sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id));
- Assert.Contains("User does not have two-step login enabled.", exception.Message);
- }
-
- [Theory, BitAutoData]
- public async Task ConfirmUser_TwoFactorPolicy_Enabled_Success(Organization org, OrganizationUser confirmingUser,
- [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
- [OrganizationUserPolicyDetails(PolicyType.TwoFactorAuthentication)] OrganizationUserPolicyDetails twoFactorPolicy,
- string key, SutProvider sutProvider)
- {
- var organizationUserRepository = sutProvider.GetDependency();
- var organizationRepository = sutProvider.GetDependency();
- var userRepository = sutProvider.GetDependency();
- var policyService = sutProvider.GetDependency();
- var twoFactorIsEnabledQuery = sutProvider.GetDependency();
-
- org.PlanType = PlanType.EnterpriseAnnually;
- orgUser.OrganizationId = confirmingUser.OrganizationId = org.Id;
- orgUser.UserId = user.Id;
- organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
- organizationRepository.GetByIdAsync(org.Id).Returns(org);
- userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
- twoFactorPolicy.OrganizationId = org.Id;
- policyService.GetPoliciesApplicableToUserAsync(user.Id, PolicyType.TwoFactorAuthentication).Returns(new[] { twoFactorPolicy });
- twoFactorIsEnabledQuery.TwoFactorIsEnabledAsync(Arg.Is>(ids => ids.Contains(user.Id)))
- .Returns(new List<(Guid userId, bool twoFactorIsEnabled)>() { (user.Id, true) });
-
- await sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id);
- }
-
- [Theory, BitAutoData]
- public async Task ConfirmUsers_Success(Organization org,
- OrganizationUser confirmingUser,
- [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser1,
- [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser2,
- [OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser3,
- OrganizationUser anotherOrgUser, User user1, User user2, User user3,
- [OrganizationUserPolicyDetails(PolicyType.TwoFactorAuthentication)] OrganizationUserPolicyDetails twoFactorPolicy,
- [OrganizationUserPolicyDetails(PolicyType.SingleOrg)] OrganizationUserPolicyDetails singleOrgPolicy,
- string key, SutProvider sutProvider)
- {
- var organizationUserRepository = sutProvider.GetDependency();
- var organizationRepository = sutProvider.GetDependency();
- var userRepository = sutProvider.GetDependency();
- var policyService = sutProvider.GetDependency();
- var twoFactorIsEnabledQuery = sutProvider.GetDependency();
-
- org.PlanType = PlanType.EnterpriseAnnually;
- orgUser1.OrganizationId = orgUser2.OrganizationId = orgUser3.OrganizationId = confirmingUser.OrganizationId = org.Id;
- orgUser1.UserId = user1.Id;
- orgUser2.UserId = user2.Id;
- orgUser3.UserId = user3.Id;
- anotherOrgUser.UserId = user3.Id;
- var orgUsers = new[] { orgUser1, orgUser2, orgUser3 };
- organizationUserRepository.GetManyAsync(default).ReturnsForAnyArgs(orgUsers);
- organizationRepository.GetByIdAsync(org.Id).Returns(org);
- userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { user1, user2, user3 });
- twoFactorPolicy.OrganizationId = org.Id;
- policyService.GetPoliciesApplicableToUserAsync(Arg.Any(), PolicyType.TwoFactorAuthentication).Returns(new[] { twoFactorPolicy });
- twoFactorIsEnabledQuery.TwoFactorIsEnabledAsync(Arg.Is>(ids => ids.Contains(user1.Id) && ids.Contains(user2.Id) && ids.Contains(user3.Id)))
- .Returns(new List<(Guid userId, bool twoFactorIsEnabled)>()
- {
- (user1.Id, true),
- (user2.Id, false),
- (user3.Id, true)
- });
- singleOrgPolicy.OrganizationId = org.Id;
- policyService.GetPoliciesApplicableToUserAsync(user3.Id, PolicyType.SingleOrg)
- .Returns(new[] { singleOrgPolicy });
- organizationUserRepository.GetManyByManyUsersAsync(default)
- .ReturnsForAnyArgs(new[] { orgUser1, orgUser2, orgUser3, anotherOrgUser });
-
- var keys = orgUsers.ToDictionary(ou => ou.Id, _ => key);
- var result = await sutProvider.Sut.ConfirmUsersAsync(confirmingUser.OrganizationId, keys, confirmingUser.Id);
- Assert.Contains("", result[0].Item2);
- Assert.Contains("User does not have two-step login enabled.", result[1].Item2);
- Assert.Contains("Cannot confirm this member to the organization until they leave or remove all other organizations.", result[2].Item2);
- }
-
[Theory, BitAutoData]
public async Task UpdateOrganizationKeysAsync_WithoutManageResetPassword_Throws(Guid orgId, string publicKey,
string privateKey, SutProvider sutProvider)
From efd33c3301e0c526172ef8212e6a94edf4b9c887 Mon Sep 17 00:00:00 2001
From: Addison Beck
Date: Mon, 24 Mar 2025 13:33:51 -0400
Subject: [PATCH 113/184] chore: set correct version for upcoming scheduled
release (#5550)
---
Directory.Build.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index b9b8cf557a..2ede6ad8d1 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -3,7 +3,7 @@
net8.0
- 2025.3.6
+ 2025.3.3
Bit.$(MSBuildProjectName)
enable
From f1a9545a0082e00cf6f3745543fa7c3b6ca00678 Mon Sep 17 00:00:00 2001
From: Justin Baur <19896123+justindbaur@users.noreply.github.com>
Date: Mon, 24 Mar 2025 13:48:20 -0400
Subject: [PATCH 114/184] Remove unneeded exclusions (#5478)
---
src/Billing/Billing.csproj | 2 --
src/Core/Core.csproj | 2 +-
src/Infrastructure.Dapper/Infrastructure.Dapper.csproj | 2 +-
3 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/Billing/Billing.csproj b/src/Billing/Billing.csproj
index 50e372791f..f32eccfe8c 100644
--- a/src/Billing/Billing.csproj
+++ b/src/Billing/Billing.csproj
@@ -3,8 +3,6 @@
bitwarden-Billing
false
-
- $(WarningsNotAsErrors);CS9113
diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj
index 2a3edcdc00..ea72f3c785 100644
--- a/src/Core/Core.csproj
+++ b/src/Core/Core.csproj
@@ -4,7 +4,7 @@
false
bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml
- $(WarningsNotAsErrors);CS1570;CS1574;CS8602;CS9113;CS1998;CS8604
+ $(WarningsNotAsErrors);CS1570;CS1574;CS9113;CS1998
diff --git a/src/Infrastructure.Dapper/Infrastructure.Dapper.csproj b/src/Infrastructure.Dapper/Infrastructure.Dapper.csproj
index 19512670ce..c51af39824 100644
--- a/src/Infrastructure.Dapper/Infrastructure.Dapper.csproj
+++ b/src/Infrastructure.Dapper/Infrastructure.Dapper.csproj
@@ -2,7 +2,7 @@
- $(WarningsNotAsErrors);CS8618;CS4014
+ $(WarningsNotAsErrors);CS8618
From 229aecb55cb7ebf5450feb2d0459266384405e1a Mon Sep 17 00:00:00 2001
From: Matt Andreko
Date: Mon, 24 Mar 2025 14:20:42 -0400
Subject: [PATCH 115/184] Update SARIF upload to use proper branch (#5534)
---
.github/workflows/build.yml | 2 ++
.github/workflows/scan.yml | 2 ++
2 files changed, 4 insertions(+)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 3b96eeb468..8f125b7811 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -317,6 +317,8 @@ jobs:
uses: github/codeql-action/upload-sarif@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
with:
sarif_file: ${{ steps.container-scan.outputs.sarif }}
+ sha: ${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.sha || github.sha }}
+ ref: ${{ contains(github.event_name, 'pull_request') && format('refs/pull/{0}/head', github.event.pull_request.number) || github.ref }}
upload:
name: Upload
diff --git a/.github/workflows/scan.yml b/.github/workflows/scan.yml
index 1fa5c9587c..fe88782e35 100644
--- a/.github/workflows/scan.yml
+++ b/.github/workflows/scan.yml
@@ -49,6 +49,8 @@ jobs:
uses: github/codeql-action/upload-sarif@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
with:
sarif_file: cx_result.sarif
+ sha: ${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.sha || github.sha }}
+ ref: ${{ contains(github.event_name, 'pull_request') && format('refs/pull/{0}/head', github.event.pull_request.number) || github.ref }}
quality:
name: Quality scan
From 653b12a73171f6ec3663d91803cef03ba87ca3f0 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Mon, 24 Mar 2025 17:46:10 -0400
Subject: [PATCH 116/184] Fix Git hash
---
Directory.Build.props | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index 2ede6ad8d1..1cdb29febb 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -56,16 +56,11 @@
This section is for getting & setting the gitHash value, which can easily be accessed
via the Core.Utilities.AssemblyHelpers class.
-->
-
-
-
-
-
-
+
<_Parameter1>GitHash
- <_Parameter2>$(SourceRevisionId)
+ <_Parameter2>HASH_HERE
From 5797b78843d08c9cb12c784d6fc48417632bc5da Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Mon, 24 Mar 2025 17:48:25 -0400
Subject: [PATCH 117/184] Set hash
---
.github/workflows/build.yml | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 212f86b4fa..1e8ed9b9f9 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -95,6 +95,15 @@ jobs:
else
echo "is_publish_branch=false" >> $GITHUB_ENV
fi
+
+ - name: Set SourceRevisionId
+ run: |
+ GIT_HASH=$(git describe --long --always --dirty --exclude='*' --abbrev=8)
+ echo "GitHash: ${GIT_HASH}"
+
+ sed -i 's/HASH_HERE/$GIT_HASH/' Directory.Build.props
+ cat Directory.Build.props
+ exit 1
########## Set up Docker ##########
- name: Set up QEMU emulators
From 11ac3cde889de878114d4fd7f50c52cf6118bbbd Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Mon, 24 Mar 2025 17:58:42 -0400
Subject: [PATCH 118/184] Change single-quotes to double-quotes
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1e8ed9b9f9..cfd426e088 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -101,7 +101,7 @@ jobs:
GIT_HASH=$(git describe --long --always --dirty --exclude='*' --abbrev=8)
echo "GitHash: ${GIT_HASH}"
- sed -i 's/HASH_HERE/$GIT_HASH/' Directory.Build.props
+ sed -i "s/HASH_HERE/$GIT_HASH/" Directory.Build.props
cat Directory.Build.props
exit 1
From b6cfcf12f6287ec095803ab3be14d52d8d004fc8 Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Mon, 24 Mar 2025 18:05:02 -0400
Subject: [PATCH 119/184] Test full build
---
.github/workflows/build.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index cfd426e088..73d082b9d8 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -103,7 +103,6 @@ jobs:
sed -i "s/HASH_HERE/$GIT_HASH/" Directory.Build.props
cat Directory.Build.props
- exit 1
########## Set up Docker ##########
- name: Set up QEMU emulators
From 7ca10c4072d8229fd633d62a8189ddb58b1684ba Mon Sep 17 00:00:00 2001
From: Vince Grassia <593223+vgrassia@users.noreply.github.com>
Date: Tue, 25 Mar 2025 10:00:10 -0400
Subject: [PATCH 120/184] Remove copy directive for git folder
---
bitwarden_license/src/Scim/Dockerfile | 1 -
bitwarden_license/src/Sso/Dockerfile | 1 -
src/Admin/Dockerfile | 1 -
src/Api/Dockerfile | 1 -
src/Billing/Dockerfile | 1 -
src/Events/Dockerfile | 1 -
src/EventsProcessor/Dockerfile | 1 -
src/Icons/Dockerfile | 1 -
src/Identity/Dockerfile | 1 -
src/Notifications/Dockerfile | 1 -
util/Attachments/Dockerfile | 1 -
util/MsSqlMigratorUtility/Dockerfile | 1 -
util/Setup/Dockerfile | 1 -
13 files changed, 13 deletions(-)
diff --git a/bitwarden_license/src/Scim/Dockerfile b/bitwarden_license/src/Scim/Dockerfile
index 9aa08e880e..1d01ffa07c 100644
--- a/bitwarden_license/src/Scim/Dockerfile
+++ b/bitwarden_license/src/Scim/Dockerfile
@@ -38,7 +38,6 @@ COPY src/Core/. ./src/Core/
COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
-COPY .git/. ./.git/
# Build project
WORKDIR /source/bitwarden_license/src/Scim
diff --git a/bitwarden_license/src/Sso/Dockerfile b/bitwarden_license/src/Sso/Dockerfile
index 9de0519605..fc58c334c4 100644
--- a/bitwarden_license/src/Sso/Dockerfile
+++ b/bitwarden_license/src/Sso/Dockerfile
@@ -55,7 +55,6 @@ COPY src/Core/. ./src/Core/
COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
-COPY .git/. ./.git/
# Build project
WORKDIR /source/bitwarden_license/src/Sso
diff --git a/src/Admin/Dockerfile b/src/Admin/Dockerfile
index 68a147b7cc..2e3b550387 100644
--- a/src/Admin/Dockerfile
+++ b/src/Admin/Dockerfile
@@ -74,7 +74,6 @@ COPY util/SqliteMigrations/. ./util/SqliteMigrations/
COPY util/EfShared/. ./util/EfShared/
COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
-COPY .git/. ./.git/
# Build project
WORKDIR /source/src/Admin
diff --git a/src/Api/Dockerfile b/src/Api/Dockerfile
index 53ef5e849c..63f5cdb1f8 100644
--- a/src/Api/Dockerfile
+++ b/src/Api/Dockerfile
@@ -42,7 +42,6 @@ COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
-COPY .git/. ./.git/
# Build project
WORKDIR /source/src/Api
diff --git a/src/Billing/Dockerfile b/src/Billing/Dockerfile
index 11b1539a11..cc327eaa64 100644
--- a/src/Billing/Dockerfile
+++ b/src/Billing/Dockerfile
@@ -38,7 +38,6 @@ COPY src/Core/. ./src/Core/
COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
-COPY .git/. ./.git/
# Build project
WORKDIR /source/src/Billing
diff --git a/src/Events/Dockerfile b/src/Events/Dockerfile
index 3d2c119e11..9882c8dec0 100644
--- a/src/Events/Dockerfile
+++ b/src/Events/Dockerfile
@@ -38,7 +38,6 @@ COPY src/Core/. ./src/Core/
COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
-COPY .git/. ./.git/
# Build project
WORKDIR /source/src/Events
diff --git a/src/EventsProcessor/Dockerfile b/src/EventsProcessor/Dockerfile
index 10de833d4e..47ef10edac 100644
--- a/src/EventsProcessor/Dockerfile
+++ b/src/EventsProcessor/Dockerfile
@@ -38,7 +38,6 @@ COPY src/Core/. ./src/Core/
COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
-COPY .git/. ./.git/
# Build project
WORKDIR /source/src/EventsProcessor
diff --git a/src/Icons/Dockerfile b/src/Icons/Dockerfile
index 39dcb01059..7bfa526908 100644
--- a/src/Icons/Dockerfile
+++ b/src/Icons/Dockerfile
@@ -38,7 +38,6 @@ COPY src/Core/. ./src/Core/
COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
-COPY .git/. ./.git/
# Build project
WORKDIR /source/src/Icons
diff --git a/src/Identity/Dockerfile b/src/Identity/Dockerfile
index aa1d9e4a28..9ce6dc513a 100644
--- a/src/Identity/Dockerfile
+++ b/src/Identity/Dockerfile
@@ -38,7 +38,6 @@ COPY src/Core/. ./src/Core/
COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
-COPY .git/. ./.git/
# Build project
WORKDIR /source/src/Identity
diff --git a/src/Notifications/Dockerfile b/src/Notifications/Dockerfile
index 6953e8f60c..9d3a0da449 100644
--- a/src/Notifications/Dockerfile
+++ b/src/Notifications/Dockerfile
@@ -38,7 +38,6 @@ COPY src/Notifications/. ./src/Notifications/
COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
-COPY .git/. ./.git/
# Build project
WORKDIR /source/src/Notifications
diff --git a/util/Attachments/Dockerfile b/util/Attachments/Dockerfile
index 0b04dc88aa..d1c3575616 100644
--- a/util/Attachments/Dockerfile
+++ b/util/Attachments/Dockerfile
@@ -30,7 +30,6 @@ RUN . /tmp/rid.txt && dotnet restore -r $RID
# Copy required project files
WORKDIR /source
COPY util/Server/. ./util/Server/
-COPY .git/. ./.git/
# Build project
WORKDIR /source/util/Server
diff --git a/util/MsSqlMigratorUtility/Dockerfile b/util/MsSqlMigratorUtility/Dockerfile
index 9efc0bbdf9..a7afa9f95e 100644
--- a/util/MsSqlMigratorUtility/Dockerfile
+++ b/util/MsSqlMigratorUtility/Dockerfile
@@ -35,7 +35,6 @@ WORKDIR /source
COPY src/Core/. ./src/Core/
COPY util/Migrator/. ./util/Migrator/
COPY util/MsSqlMigratorUtility/. ./util/MsSqlMigratorUtility/
-COPY .git/. ./.git/
# Build project
WORKDIR /source/util/MsSqlMigratorUtility
diff --git a/util/Setup/Dockerfile b/util/Setup/Dockerfile
index a4d292565f..46b6b5916f 100644
--- a/util/Setup/Dockerfile
+++ b/util/Setup/Dockerfile
@@ -34,7 +34,6 @@ WORKDIR /source
COPY src/Core/. ./src/Core/
COPY util/Migrator/. ./util/Migrator/
COPY util/Setup/. ./util/Setup/
-COPY .git/. ./.git/
# Build project
WORKDIR /source/util/Setup
From 55980e8038daadca5a2831ac7d086e742c393fef Mon Sep 17 00:00:00 2001
From: Bernd Schoolmann
Date: Tue, 25 Mar 2025 15:23:01 +0100
Subject: [PATCH 121/184] [PM-16603] Add userkey rotation v2 (#5204)
* Implement userkey rotation v2
* Update request models
* Cleanup
* Update tests
* Improve test
* Add tests
* Fix formatting
* Fix test
* Remove whitespace
* Fix namespace
* Enable nullable on models
* Fix build
* Add tests and enable nullable on masterpasswordunlockdatamodel
* Fix test
* Remove rollback
* Add tests
* Make masterpassword hint optional
* Update user query
* Add EF test
* Improve test
* Cleanup
* Set masterpassword hint
* Remove connection close
* Add tests for invalid kdf types
* Update test/Core.Test/KeyManagement/UserKey/RotateUserAccountKeysCommandTests.cs
Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>
* Fix formatting
* Update src/Api/KeyManagement/Models/Requests/RotateAccountKeysAndDataRequestModel.cs
Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>
* Update src/Api/Auth/Models/Request/Accounts/MasterPasswordUnlockDataModel.cs
Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>
* Update src/Api/Auth/Models/Request/Accounts/MasterPasswordUnlockDataModel.cs
Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>
* Update src/Api/KeyManagement/Models/Requests/AccountKeysRequestModel.cs
Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>
* Fix imports
* Fix tests
* Remove null check
* Add rollback
---------
Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>
---
.../Auth/Controllers/AccountsController.cs | 1 +
.../Accounts/MasterPasswordUnlockDataModel.cs | 66 +++++++++
.../AccountsKeyManagementController.cs | 83 ++++++++++-
.../Requests/AccountKeysRequestModel.cs | 10 ++
.../RotateAccountKeysAndDataRequestModel.cs | 13 ++
.../Models/Requests/UnlockDataRequestModel.cs | 16 +++
.../Models/Requests/UserDataRequestModel.cs | 12 ++
.../UserServiceCollectionExtensions.cs | 1 +
src/Core/Constants.cs | 3 +
.../Models/Data/MasterPasswordUnlockData.cs | 34 +++++
.../Models/Data/RotateUserAccountKeysData.cs | 28 ++++
.../UserKey/IRotateUserAccountKeysCommand.cs | 20 +++
.../RotateUserAccountkeysCommand.cs | 134 ++++++++++++++++++
src/Core/Repositories/IUserRepository.cs | 2 +
.../Repositories/UserRepository.cs | 55 ++++++-
.../Repositories/UserRepository.cs | 47 ++++++
.../AccountsKeyManagementControllerTests.cs | 91 ++++++++++++
.../AccountsKeyManagementControllerTests.cs | 85 +++++++++++
.../Request/MasterPasswordUnlockDataModel.cs | 68 +++++++++
.../RotateUserAccountKeysCommandTests.cs | 120 ++++++++++++++++
.../UserKey/RotateUserKeyCommandTests.cs | 2 +-
.../Repositories/UserRepositoryTests.cs | 24 ++++
22 files changed, 906 insertions(+), 9 deletions(-)
create mode 100644 src/Api/Auth/Models/Request/Accounts/MasterPasswordUnlockDataModel.cs
create mode 100644 src/Api/KeyManagement/Models/Requests/AccountKeysRequestModel.cs
create mode 100644 src/Api/KeyManagement/Models/Requests/RotateAccountKeysAndDataRequestModel.cs
create mode 100644 src/Api/KeyManagement/Models/Requests/UnlockDataRequestModel.cs
create mode 100644 src/Api/KeyManagement/Models/Requests/UserDataRequestModel.cs
create mode 100644 src/Core/KeyManagement/Models/Data/MasterPasswordUnlockData.cs
create mode 100644 src/Core/KeyManagement/Models/Data/RotateUserAccountKeysData.cs
create mode 100644 src/Core/KeyManagement/UserKey/IRotateUserAccountKeysCommand.cs
create mode 100644 src/Core/KeyManagement/UserKey/Implementations/RotateUserAccountkeysCommand.cs
create mode 100644 test/Api.Test/KeyManagement/Models/Request/MasterPasswordUnlockDataModel.cs
create mode 100644 test/Core.Test/KeyManagement/UserKey/RotateUserAccountKeysCommandTests.cs
diff --git a/src/Api/Auth/Controllers/AccountsController.cs b/src/Api/Auth/Controllers/AccountsController.cs
index 6c19049c49..2555a6fe2d 100644
--- a/src/Api/Auth/Controllers/AccountsController.cs
+++ b/src/Api/Auth/Controllers/AccountsController.cs
@@ -355,6 +355,7 @@ public class AccountsController : Controller
throw new BadRequestException(ModelState);
}
+ [Obsolete("Replaced by the safer rotate-user-account-keys endpoint.")]
[HttpPost("key")]
public async Task PostKey([FromBody] UpdateKeyRequestModel model)
{
diff --git a/src/Api/Auth/Models/Request/Accounts/MasterPasswordUnlockDataModel.cs b/src/Api/Auth/Models/Request/Accounts/MasterPasswordUnlockDataModel.cs
new file mode 100644
index 0000000000..ba57788cec
--- /dev/null
+++ b/src/Api/Auth/Models/Request/Accounts/MasterPasswordUnlockDataModel.cs
@@ -0,0 +1,66 @@
+#nullable enable
+
+using System.ComponentModel.DataAnnotations;
+using Bit.Core.Enums;
+using Bit.Core.KeyManagement.Models.Data;
+using Bit.Core.Utilities;
+
+namespace Bit.Api.Auth.Models.Request.Accounts;
+
+public class MasterPasswordUnlockDataModel : IValidatableObject
+{
+ public required KdfType KdfType { get; set; }
+ public required int KdfIterations { get; set; }
+ public int? KdfMemory { get; set; }
+ public int? KdfParallelism { get; set; }
+
+ [StrictEmailAddress]
+ [StringLength(256)]
+ public required string Email { get; set; }
+ [StringLength(300)]
+ public required string MasterKeyAuthenticationHash { get; set; }
+ [EncryptedString] public required string MasterKeyEncryptedUserKey { get; set; }
+ [StringLength(50)]
+ public string? MasterPasswordHint { get; set; }
+
+ public IEnumerable Validate(ValidationContext validationContext)
+ {
+ if (KdfType == KdfType.PBKDF2_SHA256)
+ {
+ if (KdfMemory.HasValue || KdfParallelism.HasValue)
+ {
+ yield return new ValidationResult("KdfMemory and KdfParallelism must be null for PBKDF2_SHA256", new[] { nameof(KdfMemory), nameof(KdfParallelism) });
+ }
+ }
+ else if (KdfType == KdfType.Argon2id)
+ {
+ if (!KdfMemory.HasValue || !KdfParallelism.HasValue)
+ {
+ yield return new ValidationResult("KdfMemory and KdfParallelism must have values for Argon2id", new[] { nameof(KdfMemory), nameof(KdfParallelism) });
+ }
+ }
+ else
+ {
+ yield return new ValidationResult("Invalid KdfType", new[] { nameof(KdfType) });
+ }
+ }
+
+ public MasterPasswordUnlockData ToUnlockData()
+ {
+ var data = new MasterPasswordUnlockData
+ {
+ KdfType = KdfType,
+ KdfIterations = KdfIterations,
+ KdfMemory = KdfMemory,
+ KdfParallelism = KdfParallelism,
+
+ Email = Email,
+
+ MasterKeyAuthenticationHash = MasterKeyAuthenticationHash,
+ MasterKeyEncryptedUserKey = MasterKeyEncryptedUserKey,
+ MasterPasswordHint = MasterPasswordHint
+ };
+ return data;
+ }
+
+}
diff --git a/src/Api/KeyManagement/Controllers/AccountsKeyManagementController.cs b/src/Api/KeyManagement/Controllers/AccountsKeyManagementController.cs
index b8d5e30949..85e0981f22 100644
--- a/src/Api/KeyManagement/Controllers/AccountsKeyManagementController.cs
+++ b/src/Api/KeyManagement/Controllers/AccountsKeyManagementController.cs
@@ -1,10 +1,23 @@
#nullable enable
+using Bit.Api.AdminConsole.Models.Request.Organizations;
+using Bit.Api.Auth.Models.Request;
+using Bit.Api.Auth.Models.Request.WebAuthn;
using Bit.Api.KeyManagement.Models.Requests;
+using Bit.Api.KeyManagement.Validators;
+using Bit.Api.Tools.Models.Request;
+using Bit.Api.Vault.Models.Request;
using Bit.Core;
+using Bit.Core.Auth.Entities;
+using Bit.Core.Auth.Models.Data;
+using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.KeyManagement.Commands.Interfaces;
+using Bit.Core.KeyManagement.Models.Data;
+using Bit.Core.KeyManagement.UserKey;
using Bit.Core.Repositories;
using Bit.Core.Services;
+using Bit.Core.Tools.Entities;
+using Bit.Core.Vault.Entities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -19,18 +32,45 @@ public class AccountsKeyManagementController : Controller
private readonly IOrganizationUserRepository _organizationUserRepository;
private readonly IRegenerateUserAsymmetricKeysCommand _regenerateUserAsymmetricKeysCommand;
private readonly IUserService _userService;
+ private readonly IRotateUserAccountKeysCommand _rotateUserAccountKeysCommand;
+ private readonly IRotationValidator, IEnumerable> _cipherValidator;
+ private readonly IRotationValidator, IEnumerable> _folderValidator;
+ private readonly IRotationValidator, IReadOnlyList> _sendValidator;
+ private readonly IRotationValidator, IEnumerable>
+ _emergencyAccessValidator;
+ private readonly IRotationValidator,
+ IReadOnlyList>
+ _organizationUserValidator;
+ private readonly IRotationValidator, IEnumerable>
+ _webauthnKeyValidator;
public AccountsKeyManagementController(IUserService userService,
IFeatureService featureService,
IOrganizationUserRepository organizationUserRepository,
IEmergencyAccessRepository emergencyAccessRepository,
- IRegenerateUserAsymmetricKeysCommand regenerateUserAsymmetricKeysCommand)
+ IRegenerateUserAsymmetricKeysCommand regenerateUserAsymmetricKeysCommand,
+ IRotateUserAccountKeysCommand rotateUserKeyCommandV2,
+ IRotationValidator