UpstreamDataInc / goosebit

A simplistic, opinionated remote update server implementing hawkBit™'s DDI API.
https://goosebit.rtfd.io
Apache License 2.0
18 stars 3 forks source link

Add Docker (Compose) support #52

Closed easybe closed 2 months ago

easybe commented 2 months ago

A first stab at #31 and #54.

To do:


This can be tested with:

docker compose up --build
b-rowan commented 2 months ago

Regarding CI, I already have an action set up for version releasing, I think we could add a build and push to docker there.

The only concerns I have is we have to figure out how to update the version in the docker compose.

b-rowan commented 2 months ago

Regarding CI, I already have an action set up for version releasing, I think we could add a build and push to docker there.

The only concerns I have is we have to figure out how to update the version in the docker compose.

Here is a GitHub guide on doing it using actions. I have added a DOCKER_USERNAME and DOCKER_PASSWORD value to the secrets for the repo, so those should be usable. This will push to the upstreamdata docker page on docker hub.

https://docs.github.com/en/actions/publishing-packages/publishing-docker-images

easybe commented 2 months ago

The only concerns I have is we have to figure out how to update the version in the docker compose.

Yes, that is a tricky one. It will be hard to avoid having the version in 2 places. However, the Compose file shall only serve as an example or for development. Build and push I plan to do with GitHub Actions directly.

For development, it would actually make sense to have the source mounted in instead.

b-rowan commented 2 months ago

Configure linter for YAML (the whole world uses 2 spaces for Docker Compose files)

I generally like to keep things consistent across the repo, meaning 4 spaces indentation for all files. I'm not strictly opposed to this for yaml files, but something we should do some deliberation about.

For reference, this is handled by prettier, which does both HTML and YAML files. I want to keep HTML at 4 spaces, but if we wanted to handle YAML differently we would have to figure out how to in .prettierrc.yaml.

b-rowan commented 2 months ago

Configure linter for YAML (the whole world uses 2 spaces for Docker Compose files)

I generally like to keep things consistent across the repo, meaning 4 spaces indentation for all files. I'm not strictly opposed to this for yaml files, but something we should do some deliberation about.

For reference, this is handled by prettier, which does both HTML and YAML files. I want to keep HTML at 4 spaces, but if we wanted to handle YAML differently we would have to figure out how to in .prettierrc.yaml.

https://stackoverflow.com/questions/56464727/different-prettier-rules-for-different-file-types

easybe commented 2 months ago

Configure linter for YAML (the whole world uses 2 spaces for Docker Compose files)

I generally like to keep things consistent across the repo, meaning 4 spaces indentation for all files. I'm not strictly opposed to this for yaml files, but something we should do some deliberation about.

For reference, this is handled by prettier, which does both HTML and YAML files. I want to keep HTML at 4 spaces, but if we wanted to handle YAML differently we would have to figure out how to in .prettierrc.yaml.

I get your point. I generally also use 4 spaces. However, as pretty much all YAML out there is indented with 2 spaces, my eyes got used to it, but more importantly, it makes copying & pasting from the internet easier.

b-rowan commented 2 months ago

I get your point. I generally also use 4 spaces. However, as pretty much all YAML out there is indented with 2 spaces, my eyes got used to it, but more importantly, it makes copying & pasting from the internet easier.

Ok, let's move forward with 2 space yaml then. I think that link I provided should be enough info to configure prettier, though it will need to be converted into yaml.

easybe commented 2 months ago

I get your point. I generally also use 4 spaces. However, as pretty much all YAML out there is indented with 2 spaces, my eyes got used to it, but more importantly, it makes copying & pasting from the internet easier.

Ok, let's move forward with 2 space yaml then. I think that link I provided should be enough info to configure prettier, though it will need to be converted into yaml.

59

easybe commented 2 months ago

Concerning CI, what I got so far seems to work: https://github.com/UpstreamDataInc/goosebit/actions/runs/10322906355

To test the actual push to the registry is a little bit of a challenge though, as the workflow is only meant to be run on release.

I will come up with a strategy and start getting things ready for integration.

b-rowan commented 2 months ago

If you only want to run on release, I use this file for release to push to PyPi- https://github.com/UpstreamDataInc/goosebit/blob/master/.github/workflows/python-publish.yml

easybe commented 2 months ago

@b-rowan I would assume that the upstreamdata/goosebit repository needs to be manually created on Docker Hub.

b-rowan commented 2 months ago

Ok, let me try doing that, one moment.

b-rowan commented 2 months ago

Ok, repo is up on docker hub :+1:

easybe commented 2 months ago

I will split this into multiple PRs. First batch: #60, #61

b-rowan commented 2 months ago

Use gunicorn

Here's a reference from the FastAPI docs on this, basically just run with uvicorn workers.

https://fastapi.tiangolo.com/deployment/server-workers/#gunicorn-with-uvicorn-workers

easybe commented 2 months ago

Use gunicorn

Here's a reference from the FastAPI docs on this, basically just run with uvicorn workers.

https://fastapi.tiangolo.com/deployment/server-workers/#gunicorn-with-uvicorn-workers

Yes, that is what am working on. Unfortunately, I am still struggling with getting the logger to print the format I want (and lack of time as I am also working on our internal deployment). But, I am on it. My WIP branch can be found here: https://github.com/husqvarnagroup/goosebit/tree/gardena/eb/docker_compose

b-rowan commented 2 months ago

Use gunicorn

Here's a reference from the FastAPI docs on this, basically just run with uvicorn workers.

https://fastapi.tiangolo.com/deployment/server-workers/#gunicorn-with-uvicorn-workers

Yes, that is what am working on. Unfortunately, I am still struggling with getting the logger to print the format I want (and lack of time as I am also working on our internal deployment). But, I am on it. My WIP branch can be found here: https://github.com/husqvarnagroup/goosebit/tree/gardena/eb/docker_compose

All good, just wanted to help out, as I figured y'all have been busy.

easybe commented 2 months ago

Closing in favor of #88 and #109