diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 31d208c..f75f115 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -29,10 +29,10 @@ // "workload": "sudo /usr/share/dotnet/dotnet workload update", "eftool": "/usr/share/dotnet/dotnet tool install --global dotnet-ef", "system": "sudo apt update && sudo apt upgrade -y", - "backend": "cd backend && /usr/share/dotnet/dotnet restore" - // "frontend": "cd frontend && yarn install" + "backend": "cd backend && /usr/share/dotnet/dotnet restore", + "frontend": "cd frontend && yarn install" }, - "postStartCommand": "sudo /usr/share/dotnet/dotnet workload update", + "postStartCommand": "sudo /usr/share/dotnet/dotnet workload update" // Configure tool-specific properties. // "customizations": {}, diff --git a/README.md b/README.md index f4bb60a..cf83848 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,8 @@ If you want to use Kestrel as your primary web server (with no reverse proxy), y #### Data persistence Configure these options if you want to change default paths for data persistence: -- `ConnectionStrings:DataContext=Data Source=/persistence/data.db` - SQLite DB connection string (default: `/persistence/data.db`) -- `LettuceEncrypt:CertificatesPath=/persistence` - path to store Let's Encrypt certificates (default: `/persistence` for `Production` and `data.db` for `Development`) +- `ConnectionStrings:DataContext=Data Source=/persistence/data.db` - SQLite DB connection string (default: `Data Source=/persistence/data.db` for `Production` and `Data Source=data.db` for `Development`) +- `LettuceEncrypt:CertificatesPath=/persistence` - path to store Let's Encrypt certificates (default: `/persistence`) > **IMPORTANT**: default persistence paths are configured to be used in a Docker container, where the user is `root`. `/persistence` is not writtable by a non-root user, so you need either to change the paths if you want to run the app outside of a container without root privileges or run app as `sudo`. @@ -41,7 +41,7 @@ Frontend is a simple React app with Material-UI. It consumes the RESTful API pro > 🚧 WIP ## Docker -Use sample `docker-compose.yml` file to deploy the project on one server using Nginx +Use sample `docker-compose.yml` to see how to deploy project using Docker ## GitHub Actions Path: `.github/workflows` diff --git a/backend/MuiCharts.Api/Program.cs b/backend/MuiCharts.Api/Program.cs index 7caeb6f..a98fdb9 100644 --- a/backend/MuiCharts.Api/Program.cs +++ b/backend/MuiCharts.Api/Program.cs @@ -31,7 +31,9 @@ WebApplicationBuilder builder = WebApplication.CreateBuilder(args); if (builder.Configuration.GetSection("LettuceEncrypt").Exists()) builder.Services.AddLettuceEncrypt() - .PersistDataToDirectory(new DirectoryInfo("/persistence"), null); + .PersistDataToDirectory(new DirectoryInfo( + builder.Configuration.GetValue("LettuceEncrypt:CertificatesPath") ?? "/persistence" + ), null); } WebApplication app = builder.Build(); diff --git a/backend/MuiCharts.Api/appsettings.Development.json b/backend/MuiCharts.Api/appsettings.Development.json index 78e579c..fbd455b 100644 --- a/backend/MuiCharts.Api/appsettings.Development.json +++ b/backend/MuiCharts.Api/appsettings.Development.json @@ -6,6 +6,6 @@ } }, "ConnectionStrings": { - "DataContext": "Data Source=app.db" + "DataContext": "Data Source=data.db" } } diff --git a/docker-compose.yml b/docker-compose.yml index ec95a56..c6e1726 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,13 +5,21 @@ services: image: "muicharts-backend:latest" build: context: ./backend + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost/swagger"] + interval: 30s + timeout: 10s + retries: 5 ports: - "80:80" - "443:443" volumes: - - ./persistence:/persistence + - ./persistence:/var/persistence environment: - "HTTPS_PORTS=443" - "LettuceEncrypt:AcceptTermsOfService=true" - - "LettuceEncrypt:DomainNames:0=containers.xfox111.net" + - "LettuceEncrypt:DomainNames:0=example.com" + - "LettuceEncrypt:DomainNames:1=www.example.com" - "LettuceEncrypt:EmailAddress=eugene@xfox111.net" + - "ConnectionStrings:DataContext=Data Source=/var/persistence/data.db" + - "LettuceEncrypt:CertificatesPath=/var/persistence"