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