From f17a535b29a347dc96fa92280602b10222e1bd8b Mon Sep 17 00:00:00 2001 From: Shrukan Date: Sat, 12 Aug 2023 22:57:31 -0600 Subject: [PATCH] Dockerize and automate --- .gitea/workflows/build-image.yaml | 38 +++++++++++++++++++++++++++++++ Dockerfile | 21 +++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .gitea/workflows/build-image.yaml create mode 100644 Dockerfile diff --git a/.gitea/workflows/build-image.yaml b/.gitea/workflows/build-image.yaml new file mode 100644 index 0000000..294146d --- /dev/null +++ b/.gitea/workflows/build-image.yaml @@ -0,0 +1,38 @@ +name: Build and Push Prod Image +run-name: ${{ gitea.ref }} Build +on: + push: + branches: + - main + +jobs: + Build-Prod-Image: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Install Docker + run: curl -fsSL https://get.docker.com | sh + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log into Gitea + uses: docker/login-action@v1 + with: + registry: gitea.shrukanslab.xyz + username: ${{ secrets.ROBOT_USERNAME }} + password: ${{ secrets.ROBOT_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64 + push: true + tags: | + gitea.shrukanslab.xyz/tj-central-bank/backend:latest + + - name: Logout from Docker Registry + run: docker logout gitea.shrukanslab.xyz diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a4c003d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +WORKDIR /App + +# Copy everything +COPY . ./ +# Restore as distinct layers +RUN dotnet restore +# Build and publish a release +RUN dotnet publish -c Release -o out + +# Build runtime image +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS deploy +WORKDIR /App +COPY --from=build /App/out . + +ENV DOTNET_EnableDiagnostics=0 + +EXPOSE 80 + +ENTRYPOINT ["dotnet", "/App/IO.Swagger.dll"] +