From 49c8c095cb3ee09440357846d4c26e3b74d48ed9 Mon Sep 17 00:00:00 2001 From: Jamie Hodgson Date: Mon, 20 May 2024 22:03:54 +0200 Subject: [PATCH] build images --- .github/workflows/develop.yml | 23 +++++++++++ .github/workflows/main.yml | 53 +++++++++++++++++++++++++ Dockerfile.site | 12 ++++++ Estimmo.Api/appsettings.Production.json | 2 +- azure-pipelines.yml | 38 ------------------ docker-compose.yml => compose.yaml | 0 docker/api/Dockerfile | 12 ++++++ docker/postgis/Dockerfile | 4 +- 8 files changed, 104 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/develop.yml create mode 100644 .github/workflows/main.yml create mode 100644 Dockerfile.site delete mode 100644 azure-pipelines.yml rename docker-compose.yml => compose.yaml (100%) create mode 100644 docker/api/Dockerfile diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml new file mode 100644 index 0000000..aba3124 --- /dev/null +++ b/.github/workflows/develop.yml @@ -0,0 +1,23 @@ +name: Build + +on: + push: + branches: + - develop + workflow_dispatch: + +env: + FRAMEWORK: net8.0 + CONFIGURATION: Debug + DOTNET_CLI_TELEMETRY_OPTOUT: true + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Run tests + run: dotnet test --configuration $CONFIGURATION Estimmo.Test/Estimmo.Test.csproj diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..0c9eadf --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,53 @@ +name: Build and Push + +on: + push: + branches: + - master + workflow_dispatch: + +env: + FRAMEWORK: net8.0 + RUNTIME: linux-x64 + CONFIGURATION: Release + DOTNET_CLI_TELEMETRY_OPTOUT: true + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Run tests + run: dotnet test --configuration $CONFIGURATION Estimmo.Test/Estimmo.Test.csproj + + - name: Publish + run: dotnet publish -r:$RUNTIME -f:$FRAMEWORK -c:$CONFIGURATION Estimmo.sln + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push PostGIS image + uses: docker/build-push-action@v5 + with: + push: true + context: docker/postgis + file: docker/postgis/Dockerfile + tags: ghcr.io/jamie-mh/estimmo-postgis:latest + + - name: Build and push API image + uses: docker/build-push-action@v5 + with: + push: true + context: . + file: docker/api/Dockerfile + tags: ghcr.io/jamie-mh/estimmo-api:latest diff --git a/Dockerfile.site b/Dockerfile.site new file mode 100644 index 0000000..11f7bc0 --- /dev/null +++ b/Dockerfile.site @@ -0,0 +1,12 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine +LABEL org.opencontainers.image.source=https://github.com/jamie-mh/hardwaredb_asp + +RUN apk --no-cache add curl + +WORKDIR /app +COPY hardwareDB/bin/Release/net8.0/linux-x64/publish /app + +ENV PORT 8080 +EXPOSE 8080 + +ENTRYPOINT ["dotnet", "/app/hardwareDB.dll"] diff --git a/Estimmo.Api/appsettings.Production.json b/Estimmo.Api/appsettings.Production.json index 67fa879..953a070 100644 --- a/Estimmo.Api/appsettings.Production.json +++ b/Estimmo.Api/appsettings.Production.json @@ -24,6 +24,6 @@ ] }, "ConnectionStrings": { - "Main": "Host=localhost;Port=5432;Database=estimmo;Username=estimmo;Password=;" + "Main": "Host=postgis;Port=5432;Database=estimmo;Username=estimmo;Password=estimmo;" } } diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index a041d06..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,38 +0,0 @@ -trigger: -- master - -pool: - vmImage: ubuntu-latest - -variables: - configuration: 'Release' - runtimeId: 'linux-x64' - -steps: -- task: UseDotNet@2 - displayName: 'Use .NET 8 SDK' - inputs: - packageType: 'sdk' - version: 8.x - -- task: DotNetCoreCLI@2 - displayName: 'Run Tests' - inputs: - command: 'test' - arguments: '--configuration $(configuration)' - projects: 'Estimmo.Test/Estimmo.Test.csproj' - -- task: DotNetCoreCLI@2 - displayName: 'Publish' - inputs: - command: 'publish' - projects: 'Estimmo.Api/Estimmo.Api.csproj' - publishWebProjects: true - arguments: '--configuration $(configuration) --runtime $(runtimeId) --no-self-contained --output $(Build.ArtifactStagingDirectory)' - zipAfterPublish: false - -- task: PublishBuildArtifacts@1 - displayName: "Upload Artifacts" - inputs: - pathtoPublish: '$(Build.ArtifactStagingDirectory)' - artifactName: 'estimmo-api' diff --git a/docker-compose.yml b/compose.yaml similarity index 100% rename from docker-compose.yml rename to compose.yaml diff --git a/docker/api/Dockerfile b/docker/api/Dockerfile new file mode 100644 index 0000000..e2859ef --- /dev/null +++ b/docker/api/Dockerfile @@ -0,0 +1,12 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine +LABEL org.opencontainers.image.source=https://github.com/jamie-mh/estimmo-api + +RUN apk --no-cache add curl + +WORKDIR /app +COPY Estimmo.Api/bin/Release/net8.0/linux-x64/publish /app + +ENV PORT 8080 +EXPOSE 8080 + +ENTRYPOINT ["dotnet", "/app/Estimmo.Api.dll"] diff --git a/docker/postgis/Dockerfile b/docker/postgis/Dockerfile index def6097..4cc6f96 100644 --- a/docker/postgis/Dockerfile +++ b/docker/postgis/Dockerfile @@ -1,2 +1,4 @@ FROM postgis/postgis:16-3.4 -RUN apt-get update && apt-get install -y postgresql-16-tdigest \ No newline at end of file +LABEL org.opencontainers.image.source=https://github.com/jamie-mh/estimmo-api + +RUN apt-get update && apt-get install -y postgresql-16-tdigest