Skip to content

Commit

Permalink
docs: add documentation for podman installation (#482)
Browse files Browse the repository at this point in the history
* Added installation for Podman for Mac

So far so good...

---------

Co-authored-by: Ole Jørgen Skogstad <skogstad@softis.net>
  • Loading branch information
arealmaas and oskogstad authored Mar 4, 2024
1 parent ee6a575 commit c084809
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
Binary file removed .aspnet/https/webapi.pfx
Binary file not shown.
42 changes: 34 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,55 @@

### Prerequisites
- [.NET 8 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
- [Docker](https://www.docker.com/products/docker-desktop/) (Docker Desktop version 4.22 or later or Docker Compose version 2.20 or later)
- [Podman](https://podman.io/)

#### Installing Podman (Mac)

You can run the entire project locally using docker compose.
1. Install [Podman](https://podman.io/)

2. Install dependencies:
```bash
brew tap cfergeau/crc
# https://github.com/containers/podman/issues/21064
brew install vfkit
brew install docker-compose
```

3. Restart your Mac

4. Finish setup in Podman Desktop

5. Check that `Docker Compatility mode` is enabled, see bottom left corner

6. Enable privileged [testcontainers-dotnet](https://github.com/testcontainers/testcontainers-dotnet/issues/876#issuecomment-1930397928)
`echo "ryuk.container.privileged = true" >> $HOME/.testcontainers.properties`

#### Installing Podman (Windows)

TODO

#### Verify prerequisites

You can run the entire project locally using `podman compose`.
```powershell
docker compose up
podman compose up
```
The APIs SwaggerUI should now be available at [localhost:7124/swagger](https://localhost:7214/swagger/index.html)


### Running the WebApi in an IDE
If you need to debug the WebApi project in an IDE, you can alternatively run docker compose without the WebAPI.
If you need do debug the WebApi project in an IDE, you can alternatively run `podman compose` without the WebAPI.
First create a dotnet user secret for the DB connection string.

```powerhell
```powershell
dotnet user-secrets set -p .\src\Digdir.Domain.Dialogporten.WebApi\ "Infrastructure:DialogDbConnectionString" "Server=localhost;Port=5432;Database=Dialogporten;User ID=postgres;Password=supersecret;"
```

Then run docker compose without the WebAPI project.
Then run `podman compose` without the WebAPI project.
```powershell
docker compose -f docker-compose-no-webapi.yml up
podman compose -f docker-compose-no-webapi.yml up
```


## DB development
This project uses Entity Framework core to manage DB migrations. DB development can ether be done through Visual Studios Package Manager Console (PMC), or through the CLI.

Expand Down
10 changes: 4 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ services:
depends_on:
dialogporten-postgres:
condition: service_healthy

environment:
- Infrastructure:DialogDbConnectionString=${DB_CONNECTION_STRING}
- Serilog__WriteTo__0__Name=Console
- Serilog__MinimumLevel__Default=Debug
- ASPNETCORE_URLS=https://+
- ASPNETCORE_URLS=http://+:8080
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/webapi.pfx
- ASPNETCORE_Kestrel__Certificates__Default__Password=supersecret
ports:
- "7214:443"
- "7214:8080"
volumes:
- ./.aspnet/https:/https
- ./.aspnet/https:/https
5 changes: 2 additions & 3 deletions src/Digdir.Domain.Dialogporten.WebApi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0@sha256:3ff67792728179308c4bf06799d8b45d155c60fddc347acf69465a496d9a20b8 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:8.0@sha256:4b684e6c74ab8dff26ac54c79d8242b1dd05aba06c367de2b583bad79fd6399b AS build
WORKDIR /src
# Main project
COPY ["src/Digdir.Domain.Dialogporten.WebApi/Digdir.Domain.Dialogporten.WebApi.csproj", "src/Digdir.Domain.Dialogporten.WebApi/"]
# Dependencies
# Dependencies
COPY ["src/Digdir.Domain.Dialogporten.Application/Digdir.Domain.Dialogporten.Application.csproj", "src/Digdir.Domain.Dialogporten.Application/"]
COPY ["src/Digdir.Domain.Dialogporten.Domain/Digdir.Domain.Dialogporten.Domain.csproj", "src/Digdir.Domain.Dialogporten.Domain/"]
COPY ["src/Digdir.Library.Entity.Abstractions/Digdir.Library.Entity.Abstractions.csproj", "src/Digdir.Library.Entity.Abstractions/"]
Expand Down

0 comments on commit c084809

Please sign in to comment.