From 10ee66d1074a25d07088af498d8de22a3d39aa47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Henrique=20Ivanchechen?= Date: Mon, 30 Jan 2023 23:22:37 -0300 Subject: [PATCH] Adding docker and workflows --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++ .github/workflows/master.yml | 42 ++++++++++++++++++++++++++++++++++++ Dockerfile | 16 ++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/master.yml create mode 100644 Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1d1e976 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + # - name: Test + # run: dotnet test --no-build --verbosity normal + diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml new file mode 100644 index 0000000..1400569 --- /dev/null +++ b/.github/workflows/master.yml @@ -0,0 +1,42 @@ +name: Master Build + +on: + push: + branches: [ "master" ] + +jobs: + build: + name: Build and Push Docker Image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Available platforms + run: echo ${{ steps.buildx.outputs.platforms }} + + - name: Build Docker image and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: ./ + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/kasbot:latest + platforms: linux/amd64,linux/arm64 + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3cb3334 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env +WORKDIR /App + +# Copy everything +COPY . ./ +# Restore as distinct layers +RUN dotnet restore +# Build a release +RUN dotnet build -c Release -o out + +# Build runtime image +FROM mcr.microsoft.com/dotnet/aspnet:6.0 +RUN apt update && apt install -y libopus-dev opus-tools +WORKDIR /App +COPY --from=build-env /App/out . +ENTRYPOINT ["dotnet", "Kasbot.dll"] \ No newline at end of file