Dockerize and automate

This commit is contained in:
Shrukan
2023-08-12 22:57:31 -06:00
parent fdf286e22f
commit f17a535b29
2 changed files with 59 additions and 0 deletions

View File

@ -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

21
Dockerfile Normal file
View File

@ -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"]