-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Docker build script for Elsa Studio
This commit introduces a Dockerfile for the Elsa Studio application and a corresponding GitHub workflow for building and deploying the Docker image. These make it possible to automatically build and deploy Elsa Studio as a Docker image.
- Loading branch information
1 parent
c01d329
commit b553ffe
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Build and deploy Elsa SStudio reference application as Docker image | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Push Docker image to Docker Hub | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
with: | ||
platforms: all | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
# list of Docker images to use as base name for tags | ||
images: | | ||
elsaworkflows/elsa-studio-v3 | ||
flavor: | | ||
latest=true | ||
# generate Docker tags based on the following events/attributes | ||
tags: | | ||
type=sha | ||
- name: Login to DockerHub | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USER }} | ||
password: ${{ secrets.DOCKER_PASS }} | ||
|
||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v3 | ||
with: | ||
builder: ${{ steps.buildx.outputs.name }} | ||
context: . | ||
file: ./docker/ElsaStudio.Dockerfile | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
|
||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS build | ||
WORKDIR /source | ||
|
||
# copy sources. | ||
COPY src/. ./src | ||
COPY ./NuGet.Config ./ | ||
COPY *.props ./ | ||
|
||
# restore packages. | ||
RUN dotnet restore "./src/bundles/ElsaStudioWebAssembly/ElsaStudioWebAssembly.csproj" | ||
RUN dotnet restore "./src/bundles/Elsa.Studio.Web/Elsa.Studio.Web.csproj" | ||
|
||
# build and publish (UseAppHost=false creates platform independent binaries). | ||
WORKDIR /source/src/bundles/Elsa.Studio.Web | ||
RUN dotnet build "Elsa.Studio.Web.csproj" -c Release -o /app/build | ||
RUN dotnet publish "Elsa.Studio.Web.csproj" -c Release -o /app/publish /p:UseAppHost=false --no-restore -f net8.0 | ||
|
||
# move binaries into smaller base image. | ||
FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim AS base | ||
WORKDIR /app | ||
COPY --from=build /app/publish ./ | ||
|
||
EXPOSE 80/tcp | ||
EXPOSE 443/tcp | ||
ENTRYPOINT ["dotnet", "Elsa.Studio.Web.dll"] |