Skip to content

Commit

Permalink
build(webapi): containerize app
Browse files Browse the repository at this point in the history
  • Loading branch information
prenaissance committed Nov 17, 2023
1 parent 1ac9a45 commit b2a063a
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/processing-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
- master
paths:
- "src/processing/**"
- "src/common/**"
- ".github/workflows/processing-docker.yml"

env:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/webapi-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
on:
push:
branches:
- master
paths:
- "src/webapi/**"
- "src/common/**"
- ".github/workflows/webapi-docker.yml"

env:
IMAGE_VERSION: "1"
IMAGE_TAG: "${{ github.sha }}"
IMAGE_NAME: prenaissance/pricing-tf-webapi

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: prenaissance
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./src/webapi/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION }}
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
${{ env.IMAGE_NAME }}:latest
20 changes: 20 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
services:
mongo:
ports:
- 27117:27017

processing:
build:
context: .
Expand All @@ -10,3 +14,19 @@ services:
- MongoDbUrl=mongodb://mongo:27017
- MongoDbName=backpack-tf-replica
- BackpackTfCookie=${BackpackTfCookie} # Your backpack.tf cookie

webapi:
build:
context: .
dockerfile: src/webapi/Dockerfile
ports:
- 5000:8080
depends_on:
mongo:
condition: service_started
processing:
condition: service_started
environment:
- MongoDbUrl=mongodb://mongo:27017
- MongoDbName=backpack-tf-replica
- BackpackTfCookie=${BackpackTfCookie} # Your backpack.tf cookie
13 changes: 13 additions & 0 deletions src/webapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
COPY src/common/PricingTf.Common.fsproj src/common/PricingTf.Common.fsproj
COPY src/webapi/PricingTf.WebApi.csproj src/webapi/PricingTf.WebApi.csproj
RUN dotnet restore src/webapi
COPY src/common src/common
COPY src/webapi src/webapi
RUN dotnet publish src/webapi -c Release -o /out

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
COPY --from=build /out .
EXPOSE 8080
ENTRYPOINT ["dotnet", "PricingTf.WebApi.dll"]

0 comments on commit b2a063a

Please sign in to comment.