1
0
mirror of https://github.com/bitwarden/web synced 2025-12-06 00:03:28 +00:00

Add web server

This commit is contained in:
Vince Grassia
2022-04-07 12:05:30 -04:00
parent 9d2cfe4a3d
commit 8add15eae9
11 changed files with 241 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
###############################################
# Build stage #
###############################################
FROM node:16-slim AS build
FROM node:16-slim AS node-build
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@@ -14,19 +14,50 @@ COPY . .
RUN npm ci
RUN npm run dist:oss:selfhost
###############################################
# Build stage #
###############################################
FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS dotnet-build
# Add packages
RUN apk add --update-cache \
npm \
&& rm -rf /var/cache/apk/*
# Copy csproj files as distinct layers
WORKDIR /source
COPY dotnet-src/Web/*.csproj ./src/Web/
#COPY Directory.Build.props .
# Restore project dependencies and tools
WORKDIR /source/src/Web
RUN dotnet restore
# Copy required project files
WORKDIR /source
COPY dotnet-src/Web/. ./src/Web/
# Build app
WORKDIR /source/src/Web
RUN dotnet publish -c release -o /app --no-restore
###############################################
# App stage #
###############################################
FROM bitwarden/server:latest
FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine
LABEL com.bitwarden.product="bitwarden"
LABEL com.bitwarden.project="web"
ENV ASPNETCORE_ENVIRONMENT=Production
ENV ASPNETCORE_URLS http://+:5000
EXPOSE 5000
# Add packages
RUN apk add --update-cache \
curl \
&& rm -rf /var/cache/apk/*
# Create required directories
RUN mkdir -p /etc/bitwarden/web
RUN chown -R bitwarden:bitwarden /etc/bitwarden
COPY docker/confd/app-id.toml /etc/confd/conf.d/
COPY docker/confd/app-id.conf.tmpl /etc/confd/templates/
@@ -34,15 +65,20 @@ COPY docker/confd/app-id.conf.tmpl /etc/confd/templates/
RUN wget -O /usr/local/bin/confd https://github.com/kelseyhightower/confd/releases/download/v0.16.0/confd-0.16.0-linux-amd64
RUN chmod +x /usr/local/bin/confd
# Copy Web server from dotnet-build stage
COPY --from=dotnet-build /app /server
# Copy app from build stage
WORKDIR /app
COPY --from=build /source/build ./
RUN chown -R bitwarden:bitwarden /app
COPY --from=node-build /source/build ./
# Copy entrypoint script and make it executable
COPY docker/entrypoint.sh /
RUN chmod +x /entrypoint.sh
# Create non-root user to run app
RUN adduser -s /bin/false -D bitwarden && chown -R bitwarden:bitwarden /app /server /etc/bitwarden
USER bitwarden:bitwarden
HEALTHCHECK CMD curl -f http://localhost:5000 || exit 1
ENTRYPOINT ["/entrypoint.sh"]

View File

@@ -4,4 +4,4 @@
cp /etc/bitwarden/web/app-id.json /app/app-id.json
exec dotnet /bitwarden_server/Server.dll /contentRoot=/app /webRoot=. /serveUnknown=false /webVault=true
exec dotnet /server/Web.dll /contentRoot=/app /webRoot=.