Example: a Dockerfile and the workflow that publishes it
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
# Builds the Dockerfile at the root for every v* tag and pushes it to this forge's staging registry.
|
||||
# IPCR picks it up from there within a minute and publishes it on IPFS; the forge's page then
|
||||
# lists the exact `image:` line to use.
|
||||
#
|
||||
# Differences from a GitHub-hosted workflow, all needed on this forge:
|
||||
# login to localhost:5000 the staging registry, as this repository: IPCR_PUSH_TOKEN is a secret
|
||||
# the forge sets on every repository allowed to publish
|
||||
# images: localhost:5000/… this repository's own name there (no other is accepted)
|
||||
# network=host so buildx's builder can reach that registry
|
||||
# runs-on: ipcr the forge's own runner, the one that sees that registry (a Gitea app's
|
||||
# own runner, if there is one, does not)
|
||||
name: image
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
jobs:
|
||||
image:
|
||||
runs-on: ipcr
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: docker/login-action@v3
|
||||
with:
|
||||
registry: localhost:5000
|
||||
username: ${{ github.repository }}
|
||||
password: ${{ secrets.IPCR_PUSH_TOKEN }}
|
||||
- uses: docker/metadata-action@v5
|
||||
id: meta
|
||||
with:
|
||||
images: localhost:5000/${{ github.repository }}
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
type=raw,value=latest
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
driver-opts: network=host
|
||||
- uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
@@ -0,0 +1,6 @@
|
||||
# A one-page web server: busybox httpd on port 8080, as an unprivileged user.
|
||||
FROM busybox:1.37
|
||||
COPY index.html /www/index.html
|
||||
USER 1000:1000
|
||||
EXPOSE 8080
|
||||
CMD ["httpd", "-f", "-p", "8080", "-h", "/www"]
|
||||
@@ -0,0 +1,34 @@
|
||||
# ipcr-hello
|
||||
|
||||
The IPCR Forge example. A tag on this repository builds its image, IPCR publishes it on IPFS,
|
||||
and the repository is mirrored to Radicle.
|
||||
|
||||
## Try it
|
||||
|
||||
1. **Tag a release.** In Gitea: *Tags → New tag* (or *Releases → New release*), name it `v1.0.0`
|
||||
and target `main`. From a clone it works too:
|
||||
|
||||
```sh
|
||||
git tag v1.0.0 && git push origin v1.0.0
|
||||
```
|
||||
|
||||
2. **Watch the build** under *Actions*. The first build on a new server takes a few minutes more,
|
||||
while it downloads its build images.
|
||||
|
||||
3. **Find the image** on the forge's page (`ipcr-forge-<your domain>`, *Published images*), about
|
||||
a minute after the build finishes. Then on this server or on any other running IPCR:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
hello:
|
||||
image: ipcr.localhost:4767/ipns/<forge name>/gitea_admin/ipcr-hello:1.0.0
|
||||
ports: ["8080:8080"]
|
||||
```
|
||||
|
||||
## What makes it work
|
||||
|
||||
- [`.gitea/workflows/build.yml`](.gitea/workflows/build.yml) pushes to `localhost:5000`, the
|
||||
forge's staging registry. IPCR imports every tag it finds there.
|
||||
- [`Dockerfile`](Dockerfile) is an ordinary Dockerfile. Anything that builds works.
|
||||
|
||||
Copy the workflow into any public or private repository on this forge to publish it the same way.
|
||||
@@ -0,0 +1,9 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>ipcr-hello</title></head>
|
||||
<body style="font: 18px/1.6 system-ui, sans-serif; max-width: 40em; margin: 4em auto; padding: 0 1em">
|
||||
<h1>Hello from IPFS</h1>
|
||||
<p>This page is served by a container whose image was built by IPCR Forge and pulled from IPFS
|
||||
through IPCR.</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user