Open ITaluone opened 1 year ago
I've thought about this before, but wasn't sure with the configuration. The configuration is located in a local file. I think it doesn' t make sense to have that inside the container. The database and configuration should live outside the docker container so that you can easily replace the container with a new version but keep your data. And I didn't have enough spare time to try that.
I have somewhat acheived that already. For now I have a docker volume.
This is my docker compose config:
version: '3'
name: ocpp
services:
server:
image: ocpp.server:latest // <--- just moved the complied files to my container
container_name: OCPP.Server
restart: always
ports:
- [a port]:8081
volumes:
- dbdata:/db
management:
image: ocpp.management:latest // <--- just moved the complied files to my container
container_name: OCPP.Management
restart: always
ports:
- [a port]:8082
volumes:
- dbdata:/db
depends_on:
- server
volumes:
dbdata: // <--- creates a docker volume and every container mount it.. but not optimal :)
If you can somehow acheive to move the config from appsettings.json to the db..
There's no need to touch the app settings file, you can use environment variables which take priority over the app settings.
You can create a docker-compose.override.yml file with these settings. Or you can just add it to your other docker file. Anything you don't specify will still come from the appsettings. You can also set it in a .env file ofcourse.
version: '3.4'
services:
ocpp-management:
environment:
- Kestrel__Endpoints__Http__Url=http://0.0.0.0:8082
- Kestrel__Endpoints__HttpsInlineCertFile__Url=https://0.0.0.0:8092
- ServerApiUrl=http://yourserver:8081/API
- ConnectionStrings__SqlServer=Server=yourserver;Database=OCPP.Core;User Id=ocpp;Password=asdf;TrustServerCertificate=True;
- ApiKey=11112222-3333-4444-5555-666677778888
- MessageDumpDir=/log
- Users__0__Username=example
- Users__0__Password=example123
- Users__0__Administrator=true
- Users__1__Username=example2
- Users__1__Password=example123
- Users__1__Administrator=false
ocpp-server:
environment:
- Kestrel__Endpoints__Http__Url=http://0.0.0.0:8081
- Kestrel__Endpoints__HttpsInlineCertFile__Url=https://0.0.0.0:8091
- ConnectionStrings__SqlServer=Server=yourserver;Database=OCPP.Core;User Id=ocpp;Password=asdf;TrustServerCertificate=True;
- ApiKey=11112222-3333-4444-5555-666677778888
- MessageDumpDir=/log
If you need the rest of the docker-compose file or the actual Dockerfile, let me know and I can do a pull request.
Hi
I think this project is worth to be available as docker image :)
If it helps, i could provide a PR here.. so tell ma what you think :)