diff options
| author | Xe Iaso <me@xeiaso.net> | 2025-04-20 22:09:18 -0400 |
|---|---|---|
| committer | Xe Iaso <me@xeiaso.net> | 2025-04-20 22:09:18 -0400 |
| commit | d913956e760d076ff7f72622871f3fd59d8a3a8e (patch) | |
| tree | 053ce24e99e4ab1725f0c2e91718649030e605dc | |
| parent | 30aaeb2598504912dc99445dfd1c1bd84efa676e (diff) | |
| download | xesite-d913956e760d076ff7f72622871f3fd59d8a3a8e.tar.xz xesite-d913956e760d076ff7f72622871f3fd59d8a3a8e.zip | |
docker buildx bake
Signed-off-by: Xe Iaso <me@xeiaso.net>
| -rw-r--r-- | .dockerignore | 2 | ||||
| -rw-r--r-- | .envrc | 1 | ||||
| -rw-r--r-- | .github/workflows/earthly.yml | 35 | ||||
| -rw-r--r-- | docker-bake.hcl | 39 | ||||
| -rw-r--r-- | docker/patreon-saasproxy.Dockerfile | 23 | ||||
| -rw-r--r-- | docker/xesite.Dockerfile | 44 | ||||
| -rw-r--r-- | gomod2nix.toml | 162 |
7 files changed, 129 insertions, 177 deletions
diff --git a/.dockerignore b/.dockerignore index db19b0c..3308fc5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,4 +3,4 @@ frontend .env .git manifest -lume +lume
\ No newline at end of file @@ -1 +0,0 @@ -use flake diff --git a/.github/workflows/earthly.yml b/.github/workflows/earthly.yml index b76055e..fe45048 100644 --- a/.github/workflows/earthly.yml +++ b/.github/workflows/earthly.yml @@ -14,15 +14,13 @@ jobs: permissions: contents: read packages: write - env: - EARTHLY_TOKEN: ${{ secrets.EARTHLY_TOKEN }} steps: - name: Checkout repository uses: actions/checkout@v4 - - uses: earthly/actions-setup@v1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - version: "latest" # or pin to an specific version, e.g. "0.8.1" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log into registry if: github.event_name != 'pull_request' uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 @@ -30,16 +28,27 @@ jobs: registry: ghcr.io username: xe password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Docker image + + - name: Build and push if: github.event_name != 'pull_request' - id: build-and-push - run: | - earthly --org me-2625 --sat alpha --ci --push +all + id: build + uses: docker/bake-action@v6 + with: + source: . + push: true + set: | + patreon-saasproxy.tags=ghcr.io/xe/site/patreon-saasproxy:latest + xesite.tags=ghcr.io/xe/site/bin:latest + - name: Build Docker image if: github.event_name == 'pull_request' - id: build - run: | - earthly --org me-2625 --sat alpha --ci +all + uses: docker/bake-action@v6 + with: + source: . + push: true + set: | + patreon-saasproxy.tags=ghcr.io/xe/site/patreon-saasproxy:latest + xesite.tags=ghcr.io/xe/site/bin:latest deploy: name: "Deploy xesite" diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 0000000..a4e6d7e --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,39 @@ +variable "ALPINE_VERSION" { + default = "edge" +} + +variable "GO_VERSION" { + default = "1.24" +} + +group "default" { + targets = [ "patreon-saasproxy", "xesite" ] +} + +target "patreon-saasproxy" { + args = { + ALPINE_VERSION = null + GO_VERSION = null + } + context = "." + dockerfile = "./docker/patreon-saasproxy.Dockerfile" + platforms = [ "linux/amd64", "linux/arm64" ] + pull = true + tags = [ + "registry.int.xeserv.us/xe/site/patreon-saasproxy:main" + ] +} + +target "xesite" { + args = { + ALPINE_VERSION = null + GO_VERSION = null + } + context = "." + dockerfile = "./docker/xesite.Dockerfile" + platforms = [ "linux/amd64", "linux/arm64" ] + pull = true + tags = [ + "registry.int.xeserv.us/xe/site/bin:main" + ] +}
\ No newline at end of file diff --git a/docker/patreon-saasproxy.Dockerfile b/docker/patreon-saasproxy.Dockerfile new file mode 100644 index 0000000..f9fed4e --- /dev/null +++ b/docker/patreon-saasproxy.Dockerfile @@ -0,0 +1,23 @@ +ARG GO_VERSION=1.24 +ARG ALPINE_VERSION=edge +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine AS build + +ARG TARGETOS +ARG TARGETARCH + +WORKDIR /app + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . +RUN --mount=type=cache,target=/root/.cache GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -gcflags "all=-N -l" -o /app/bin/patreon-saasproxy ./cmd/patreon-saasproxy + +FROM alpine:${ALPINE_VERSION} AS run +WORKDIR /app + +COPY --from=build /app/bin/patreon-saasproxy /app/bin/patreon-saasproxy + +CMD ["/app/bin/patreon-saasproxy"] + +LABEL org.opencontainers.image.source="https://github.com/Xe/site" diff --git a/docker/xesite.Dockerfile b/docker/xesite.Dockerfile new file mode 100644 index 0000000..8236751 --- /dev/null +++ b/docker/xesite.Dockerfile @@ -0,0 +1,44 @@ +ARG GO_VERSION=1.24 +ARG ALPINE_VERSION=edge +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine AS build + +ARG TARGETOS +ARG TARGETARCH + +WORKDIR /app + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . +RUN --mount=type=cache,target=/root/.cache GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -gcflags "all=-N -l" -o /app/bin/xesite ./cmd/xesite + +FROM --platform=${BUILDPLATFORM} alpine:${ALPINE_VERSION} AS fonts + +WORKDIR /fonts +RUN apk add -U unzip ca-certificates curl \ + && curl -Lo iosevka.zip https://cdn.xeiaso.net/static/pkg/iosevka/ttf.zip \ + && unzip -d /fonts iosevka.zip + +FROM --platform=${BUILDPLATFORM} alpine:${ALPINE_VERSION} AS dhall-json + +RUN mkdir -p /app +WORKDIR /app +RUN apk add -U curl bzip2 ca-certificates \ + && curl -L -o dhall-linux.tar.bz2 https://github.com/dhall-lang/dhall-haskell/releases/download/1.42.0/dhall-json-1.7.12-x86_64-linux.tar.bz2 \ + && tar -xvjf dhall-linux.tar.bz2 \ + && mv bin/dhall-to-json . + +FROM alpine:${ALPINE_VERSION} AS run +WORKDIR /app + +RUN apk add -U ca-certificates deno typst mailcap +ENV TYPST_FONT_PATHS=/app/fonts + +COPY --from=build /app/bin/xesite /app/bin/xesite +COPY --from=fonts /fonts /app/fonts +COPY --from=dhall-json /app/dhall-to-json /usr/local/bin/dhall-to-json + +CMD ["/app/bin/xesite"] + +LABEL org.opencontainers.image.source="https://github.com/Xe/site" diff --git a/gomod2nix.toml b/gomod2nix.toml deleted file mode 100644 index 01ddd58..0000000 --- a/gomod2nix.toml +++ /dev/null @@ -1,162 +0,0 @@ -schema = 3 - -[mod] - [mod."dario.cat/mergo"] - version = "v1.0.0" - hash = "sha256-jlpc8dDj+DmiOU4gEawBu8poJJj9My0s9Mvuk9oS8ww=" - [mod."github.com/Microsoft/go-winio"] - version = "v0.6.1" - hash = "sha256-BL0BVaHtmPKQts/711W59AbHXjGKqFS4ZTal0RYnR9I=" - [mod."github.com/ProtonMail/go-crypto"] - version = "v1.0.0" - hash = "sha256-Gflazvyv+457FpUTtPafJ+SdolYSalpsU0tragTxNi8=" - [mod."github.com/bep/debounce"] - version = "v1.2.1" - hash = "sha256-7qHOp4vB0ifEseXXBuSH6W5YNImVcb8PTWSJJAMaGcU=" - [mod."github.com/cloudflare/circl"] - version = "v1.3.7" - hash = "sha256-AkOpcZ+evLxLJStvvr01+TLeWDqcLxY3e/AhGggzh40=" - [mod."github.com/cyphar/filepath-securejoin"] - version = "v0.2.4" - hash = "sha256-heCD0xMxlwnHCHcRBgTjVexHOLyWI2zRW3E8NFKoLzk=" - [mod."github.com/davecgh/go-spew"] - version = "v1.1.1" - hash = "sha256-nhzSUrE1fCkN0+RL04N4h8jWmRFPPPWbCuDc7Ss0akI=" - [mod."github.com/donatj/hmacsig"] - version = "v1.1.0" - hash = "sha256-/T7mWqQwZt+AFD/2QAYCAW/TsZptawFMl8CGWPmyhtE=" - [mod."github.com/emicklei/proto"] - version = "v1.11.2" - hash = "sha256-1j9oAuZbq5F+eY0emvivv4G/46YRoL/QzqwomuFElsw=" - [mod."github.com/emirpasic/gods"] - version = "v1.18.1" - hash = "sha256-hGDKddjLj+5dn2woHtXKUdd49/3xdsqnhx7VEdCu1m4=" - [mod."github.com/facebookgo/ensure"] - version = "v0.0.0-20200202191622-63f1cf65ac4c" - hash = "sha256-ZvQLMu0LBtRB4lMgY4DlsKxiRUzmh8W4KvGYJF4icRc=" - [mod."github.com/facebookgo/flagenv"] - version = "v0.0.0-20160425205200-fcd59fca7456" - hash = "sha256-Dx2QQ7FngN64CDL1I3jQG4JOzzCKnt6MsbnVRzzh7jA=" - [mod."github.com/facebookgo/subset"] - version = "v0.0.0-20200203212716-c811ad88dec4" - hash = "sha256-oBhWz9Haw/ZuqJofQ7psThNrr1f6GHHgxq8agev7TOo=" - [mod."github.com/getkin/kin-openapi"] - version = "v0.120.0" - hash = "sha256-x5BjdRncVOy3t7HqmA6IwfYDg/xy3BsGjFawrnrXcko=" - [mod."github.com/go-faker/faker/v4"] - version = "v4.3.0" - hash = "sha256-Y70kJJAMfQ6CBvZO+28gpKGSni/EFMNIGKUzc299Sss=" - [mod."github.com/go-git/gcfg"] - version = "v1.5.1-0.20230307220236-3a3c6141e376" - hash = "sha256-f4k0gSYuo0/q3WOoTxl2eFaj7WZpdz29ih6CKc8Ude8=" - [mod."github.com/go-git/go-billy/v5"] - version = "v5.5.0" - hash = "sha256-4XUoD2bOCMCdu83egb/y8kY/Fm0s1rWgPMtiahh38OQ=" - [mod."github.com/go-git/go-git/v5"] - version = "v5.11.0" - hash = "sha256-2yUM/FlV+nYxacVynJCnDZeMub4Iu8JL2WBHmlnwOkE=" - [mod."github.com/go-openapi/jsonpointer"] - version = "v0.20.2" - hash = "sha256-z9IZxP+JvJ1WvrHE7qbAZQqJ3XMx1uD0S611shTMna8=" - [mod."github.com/go-openapi/swag"] - version = "v0.22.9" - hash = "sha256-rH8EMuDAAKhyNjo+CpQmlmqTc9aPzEFkRptYCenw+xE=" - [mod."github.com/golang/groupcache"] - version = "v0.0.0-20210331224755-41bb18bfe9da" - hash = "sha256-7Gs7CS9gEYZkbu5P4hqPGBpeGZWC64VDwraSKFF+VR0=" - [mod."github.com/golang/protobuf"] - version = "v1.5.3" - hash = "sha256-svogITcP4orUIsJFjMtp+Uv1+fKJv2Q5Zwf2dMqnpOQ=" - [mod."github.com/invopop/yaml"] - version = "v0.2.0" - hash = "sha256-RxeDuvwOSWYaLc8Q7T39rfFT3bZX3g9Bu0RFwxH6sLw=" - [mod."github.com/jbenet/go-context"] - version = "v0.0.0-20150711004518-d14ea06fba99" - hash = "sha256-VANNCWNNpARH/ILQV9sCQsBWgyL2iFT+4AHZREpxIWE=" - [mod."github.com/joho/godotenv"] - version = "v1.5.1" - hash = "sha256-kA0osKfsc6Kp+nuGTRJyXZZlJt1D/kuEazKMWYCWcQ8=" - [mod."github.com/josharian/intern"] - version = "v1.0.0" - hash = "sha256-LJR0QE2vOQ2/2shBbO5Yl8cVPq+NFrE3ers0vu9FRP0=" - [mod."github.com/kevinburke/ssh_config"] - version = "v1.2.0" - hash = "sha256-Ta7ZOmyX8gG5tzWbY2oES70EJPfI90U7CIJS9EAce0s=" - [mod."github.com/mailru/easyjson"] - version = "v0.7.7" - hash = "sha256-NVCz8MURpxgOjHXqxOZExqV4bnpHggpeAOyZDArjcy4=" - [mod."github.com/mohae/deepcopy"] - version = "v0.0.0-20170929034955-c48cc78d4826" - hash = "sha256-TQMmKqIYwVhmMVh4RYQkAui97Eyj7poLmcAuDcHXsEk=" - [mod."github.com/perimeterx/marshmallow"] - version = "v1.1.5" - hash = "sha256-fFWjg0FNohDSV0/wUjQ8fBq1g8h6yIqTrHkxqL2Tt0s=" - [mod."github.com/pjbgf/sha1cd"] - version = "v0.3.0" - hash = "sha256-kX9BdLh2dxtGNaDvc24NORO+C0AZ7JzbrXrtecCdB7w=" - [mod."github.com/pmezard/go-difflib"] - version = "v1.0.0" - hash = "sha256-/FtmHnaGjdvEIKAJtrUfEhV7EVo5A/eYrtdnUkuxLDA=" - [mod."github.com/sergi/go-diff"] - version = "v1.3.1" - hash = "sha256-XLA/BLIPuUU76yikXqIeRSXr7T7A3Uz6I27+mDxGj7w=" - [mod."github.com/skeema/knownhosts"] - version = "v1.2.1" - hash = "sha256-u0jB6ahTdGa+SvcIvPNRLnbSHvgmW9X/ThRq0nWQrJs=" - [mod."github.com/stretchr/testify"] - version = "v1.8.4" - hash = "sha256-MoOmRzbz9QgiJ+OOBo5h5/LbilhJfRUryvzHJmXAWjo=" - [mod."github.com/twitchtv/twirp"] - version = "v8.1.3+incompatible" - hash = "sha256-j1h9YE3wl9h36DfPf92To1H/PwNk4CgerOARNO3HK1w=" - [mod."github.com/xanzy/ssh-agent"] - version = "v0.3.3" - hash = "sha256-l3pGB6IdzcPA/HLk93sSN6NM2pKPy+bVOoacR5RC2+c=" - [mod."go4.org/mem"] - version = "v0.0.0-20220726221520-4f986261bf13" - hash = "sha256-H2Fsuvzbqp/6JKzC03XPTQTSQBcGs+B5VGsBjrQDY3c=" - [mod."golang.org/x/crypto"] - version = "v0.19.0" - hash = "sha256-Vi6vY/eWNlYQ9l3Y+gA+X2+h2CmzEOrBRVFO/cnrPWc=" - [mod."golang.org/x/mod"] - version = "v0.15.0" - hash = "sha256-ANSnGmd525BfnkMZpCmu6deMPFGADtnZx3lmZpdm2aM=" - [mod."golang.org/x/net"] - version = "v0.21.0" - hash = "sha256-LfiqMpPtqvW/eLkfx6Ebr5ksqKbQli6uq06c/+XrBsw=" - [mod."golang.org/x/oauth2"] - version = "v0.17.0" - hash = "sha256-M2ZZQZt449RJL18YpzGiAiqfGsDVMsr1IVWbYp/G/go=" - [mod."golang.org/x/sys"] - version = "v0.17.0" - hash = "sha256-e0qnE+SitE02IzvnJKI4Uzpq9EOZY+zvE8Wf5b2e6Kg=" - [mod."golang.org/x/text"] - version = "v0.14.0" - hash = "sha256-yh3B0tom1RfzQBf1RNmfdNWF1PtiqxV41jW1GVS6JAg=" - [mod."golang.org/x/tools"] - version = "v0.18.0" - hash = "sha256-JVz7W13vMPfpGQ1yW+LBlT6INu3ebpjvXyChmAkm5bQ=" - [mod."google.golang.org/appengine"] - version = "v1.6.8" - hash = "sha256-decMa0MiWfW/Bzr8QPPzzpeya0YWGHhZAt4Cr/bD1wQ=" - [mod."google.golang.org/protobuf"] - version = "v1.32.0" - hash = "sha256-GJuTkMGHCzHbyK4yD5kY4oMn8wQWqgkeBK//yVDqHJk=" - [mod."gopkg.in/fsnotify.v1"] - version = "v1.4.7" - hash = "sha256-j/Ts92oXa3k1MFU7Yd8/AqafRTsFn7V2pDKCyDJLah8=" - [mod."gopkg.in/mxpv/patreon-go.v1"] - version = "v1.0.0-20171031001022-1d2f253ac700" - hash = "sha256-vo6C8nU/lG0LdtrO4396YHvVEypkXFHia5FAGjb0qoQ=" - [mod."gopkg.in/warnings.v0"] - version = "v0.1.2" - hash = "sha256-ATVL9yEmgYbkJ1DkltDGRn/auGAjqGOfjQyBYyUo8s8=" - [mod."gopkg.in/yaml.v3"] - version = "v3.0.1" - hash = "sha256-FqL9TKYJ0XkNwJFnq9j0VvJ5ZUU1RvH/52h/f5bkYAU=" - [mod."tailscale.com"] - version = "v1.58.2" - hash = "sha256-ok+xgZRbFkQcH9VR75bhHx+bRn8ymoYQeBYsMpvfGss=" - [mod."within.website/x"] - version = "v1.9.0" - hash = "sha256-3sPyOHTN7M5Ns3X//85bKomaf8ZqZ9uu4uqiinXoQIQ=" |
