Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add dockerfile and docker-compose #39

Merged
merged 3 commits into from
Jan 24, 2024
Merged

Conversation

FoxxMD
Copy link
Contributor

@FoxxMD FoxxMD commented Jan 24, 2024

Adds Dockerfile based on Linuxserver.io (LSIO) base image which includes these features:

  • Points monitor/site/static paths to separate folder outside of project dir (CONFIG_DIR) so that a bind mount can be used
    • Enables end-user to persist these config files/dir to a folder on the host system for easy editing and persistence between image updates/container recreation
  • Using LSIO base image enables usage of PUID and PGID environmental variables to avoid file permissions for bound folder when running docker on a linux host
  • Uses LSIO s6-init to run a script on container start that populates CONFIG_DIR with project default /static and monitor.yaml/site.yaml examples as well as ensuring CONFIG_DIR file ownership match the host
  • Uses build stages to minimize final image

@FoxxMD
Copy link
Contributor Author

FoxxMD commented Jan 24, 2024

I also added a github action to automate publishing docker image to dockerhub and github packages. Using the worflow is optional and triggered based on setting variables in the repository settings so you can safely merge this without using it.

Triggers on these actions and publishes accordingly:

  • On commit to main branch => published to latest tag
  • On release => published using release tag

To enable

  • Go to repository settings -> secrets and variables -> actions
    • Add repository secrets
      • DOCKER_USERNAME - your dockerhub username
      • DOCKER_PASSWORD - your dockerhub password
    • Add repository variables
      • DOCKERHUB_IMAGE_NAME - the full name of the dockerhub image IE rajnandan1/kener
      • GHCR_IMAGE_NAME - (Optional) the full name of the GHCR image IE ghcr.io/rajnandan1/kener
  • Go to repository settings -> Actions -> General
    • Action permissions -> Allow all actions...
    • Workflow permissions -> Read and write permissions
    • Save

To "enable" publishing to each package repository you must set the "image name" variables. If those are not set the worflow will not run for that repo IE

  • GHCR_IMAGE_NAME
    • Set in variables -> Will try to publish
    • Not set in variables -> Will skip
  • DOCKERHUB_IMAGE_NAME
    • Set in variables -> Will try to publish
    • Not set in variables -> Will skip

Multi-architecture builds

I haven't tested it but this image should be fine for building to arm as well as x86. To enable arm builds in actions edit publishImages.yml and replace

platforms: linux/amd64

with

platforms: linux/amd64,linux/arm64

Copy link
Owner

@rajnandan1 rajnandan1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rajnandan1 rajnandan1 merged commit cbcdebb into rajnandan1:main Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants