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

Docker Image Creation on Release #564

Closed
alehechka opened this issue Feb 27, 2024 · 3 comments
Closed

Docker Image Creation on Release #564

alehechka opened this issue Feb 27, 2024 · 3 comments

Comments

@alehechka
Copy link
Contributor

alehechka commented Feb 27, 2024

Overview

I wanted to pitch the idea of creating an official Docker image published to DockerHub/GitHub Container Registry as an additional means to run templ commands via docker container and/or be able to use the image as a build step in our own docker images.

In my local development I like to use docker-compose to quickly spin up containers for each of my file watching processes (templ, tailwind, air) and have them all connected with the proper volumes. Since templ does not have an official docker image I've just been using the default Go image and installing templ on to it. This has been completely fine thus far and the Dockerfile is very minimal, but I thought it would be great to have an official one that comes with templ already installed.

The latter use case is also from a personal workflow in which I generate all templ Go code on build within a Dockerfile. This is also very simple setup, but would be able to further benefit from a pre-packaged image.

Let me know what you think.

@a-h
Copy link
Owner

a-h commented Feb 29, 2024

I'm up for having a Docker container for templ.

templ uses goreleaser for releases. There's support for building and pushing Docker containers in that. https://goreleaser.com/customization/docker/#how-it-works

I'd prefer to build Docker containers from Nix though.

Github has a built-in container registry, so it's straightforward to push containers.

I manually execute releases at the moment, so that I can digitally sign them with a hardware security token, but could move to using Github Actions to do the release build.

@a-h
Copy link
Owner

a-h commented Mar 17, 2024

This is no fun at all. I've spent about 2 hours messing about with Github Workflows.

https://github.com/a-h/templ/blob/main/.github/workflows/release.yml and https://github.com/a-h/templ/blob/main/.goreleaser.yaml

Running into permissions issues pushing to Github.

@a-h
Copy link
Owner

a-h commented Mar 18, 2024

OK, all sorted.

0 0 /Users/adrian/github.com/a-h/templ % docker run ghcr.io/a-h/templ:latest
usage: templ <command> [<args>...]

templ - build HTML UIs with Go

See docs at https://templ.guide

commands:
  generate   Generates Go code from templ files
  fmt        Formats templ files
  lsp        Starts a language server for templ files
  migrate    Migrates v1 templ files to v2 format
  version    Prints the version
0 0 /Users/adrian/github.com/a-h/templ % docker run ghcr.io/a-h/templ:latest version
v0.2.639

@a-h a-h closed this as completed Mar 18, 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

No branches or pull requests

2 participants