~emersion/public-inbox

sr.ht-container-compose: Add paste.sr.ht v1 APPLIED

Thorben Günther: 1
 Add paste.sr.ht

 9 files changed, 70 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/public-inbox/patches/48893/mbox | git am -3
Learn more about email & git

[PATCH sr.ht-container-compose] Add paste.sr.ht Export this patch

---
 .dockerignore    |  1 +
 .gitignore       |  1 +
 Dockerfile       | 12 ++++++++++++
 Makefile         |  1 +
 README.md        |  1 +
 compose.yaml     | 32 ++++++++++++++++++++++++++++++++
 config.ini       | 13 +++++++++++++
 hut-config       |  3 +++
 init-postgres.sh |  7 ++++++-
 9 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/.dockerignore b/.dockerignore
index 29bf816..047ccb9 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -5,3 +5,4 @@ meta.sr.ht/.git/
todo.sr.ht/.git/
scm.sr.ht/.git/
git.sr.ht/.git/
paste.sr.ht/.git/
diff --git a/.gitignore b/.gitignore
index c8cbd4d..40251c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
/todo.sr.ht/
/scm.sr.ht/
/git.sr.ht/
/paste.sr.ht/
diff --git a/Dockerfile b/Dockerfile
index fc4ac22..d95ebc1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -30,6 +30,12 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
	--mount=type=cache,target=/root/go/pkg/mod \
	cd /src/git.sr.ht && make

FROM srht-core-build as srht-paste-build
ADD paste.sr.ht /src/paste.sr.ht/
RUN --mount=type=cache,target=/root/.cache/go-build \
	--mount=type=cache,target=/root/go/pkg/mod \
	cd /src/paste.sr.ht && make

FROM srht-core as srht-meta
RUN apk -U add meta.sr.ht
COPY --from=srht-meta-build /src/meta.sr.ht /src/meta.sr.ht
@@ -49,3 +55,9 @@ COPY --from=srht-git-build /src/git.sr.ht /src/git.sr.ht
RUN passwd -u git # Unlock account to allow SSH login
ENV PYTHONPATH="${PYTHONPATH}:/src/scm.sr.ht:/src/git.sr.ht"
ENV PATH="${PATH}:/src/git.sr.ht"

FROM srht-core as srht-paste
RUN apk -U add paste.sr.ht
COPY --from=srht-paste-build /src/paste.sr.ht /src/paste.sr.ht
ENV PYTHONPATH="${PYTHONPATH}:/src/paste.sr.ht"
ENV PATH="${PATH}:/src/paste.sr.ht"
diff --git a/Makefile b/Makefile
index 1d678e3..a1a11bd 100644
--- a/Makefile
+++ b/Makefile
@@ -5,3 +5,4 @@ init:
	[ -e todo.sr.ht ] || git clone https://git.sr.ht/~sircmpwn/todo.sr.ht
	[ -e scm.sr.ht ] || git clone https://git.sr.ht/~sircmpwn/scm.sr.ht
	[ -e git.sr.ht ] || git clone https://git.sr.ht/~sircmpwn/git.sr.ht
	[ -e paste.sr.ht ] || git clone https://git.sr.ht/~sircmpwn/paste.sr.ht
diff --git a/README.md b/README.md
index 068553a..80b3cfe 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,7 @@ The following services are included:
  SMTP server at 127.0.0.1:5903 accepting mails for @todo
- git.sr.ht: web frontend at http://127.0.0.1:5001,
  SSH access at ssh://git@127.0.0.1:5901
- paste.sr.ht: web frontend at http://127.0.0.1:5011

By default, all services are started. To only start a subset, specify services
of interest as arguments, for instance:
diff --git a/compose.yaml b/compose.yaml
index 70df19c..02617a8 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -42,6 +42,7 @@ services:
      - "./meta.sr.ht/schema.sql:/data/meta.sr.ht.sql"
      - "./todo.sr.ht/schema.sql:/data/todo.sr.ht.sql"
      - "./git.sr.ht/schema.sql:/data/git.sr.ht.sql"
      - "./paste.sr.ht/schema.sql:/data/paste.sr.ht.sql"
  minio:
    image: "quay.io/minio/minio"
    environment:
@@ -191,3 +192,34 @@ services:
    ports:
      - "127.0.0.1:5901:22"
    command: /usr/sbin/sshd -D -e
  paste-api:
    <<: *srht-service
    build:
      target: srht-paste
    depends_on:
      - redis
      - postgres
    develop:
      watch:
        - path: paste.sr.ht/api
          action: rebuild
    ports:
      - "127.0.0.1:5111:5111"
    command: /src/paste.sr.ht/api/api
  paste:
    <<: *srht-service
    build:
      target: srht-paste
    develop:
      watch:
        - path: paste.sr.ht/pastesrht
          action: sync
          target: /src/paste.sr.ht/pastesrht
    depends_on:
      - redis
      - postgres
      - paste-api
      - meta
    ports:
      - "127.0.0.1:5011:5011"
    command: flask --app pastesrht.app:app --debug run --host=0.0.0.0 --port=5011
diff --git a/config.ini b/config.ini
index 392743f..0c09ebd 100644
--- a/config.ini
+++ b/config.ini
@@ -95,3 +95,16 @@ internal-ipnet=127.0.0.0/8,::1/128,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12
# so overwrite "/usr/bin/gitsrht-keys" with the latter command.
/usr/bin/gitsrht-keys=git:git
/src/git.sr.ht/gitsrht-keys/gitsrht-keys=git:git

[paste.sr.ht]
origin=http://127.0.0.1:5011
internal-origin=http://paste:5011
api-origin=http://paste-api:5111
connection-string=postgresql://postgres:postgres@postgres/paste.sr.ht?sslmode=disable
migrate-on-upgrade=yes
oauth-client-id=paste
oauth-client-secret=3387e1614fe567c1d01d7292ea1527b1
webhooks=redis://redis:6379/1

[paste.sr.ht::api]
internal-ipnet=127.0.0.0/8,::1/128,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12
diff --git a/hut-config b/hut-config
index 026a7e3..ef8800f 100644
--- a/hut-config
+++ b/hut-config
@@ -10,4 +10,7 @@ instance "localhost" {
	git {
		origin "http://localhost:5101"
	}
	paste {
		origin "http://localhost:5111"
	}
}
diff --git a/init-postgres.sh b/init-postgres.sh
index 5ac1a2d..17799f7 100755
--- a/init-postgres.sh
+++ b/init-postgres.sh
@@ -25,7 +25,9 @@ VALUES
	(NOW(), NOW(), 1, 'todo.sr.ht', 'todo', '$client_secret', '3387e161',
		'http://127.0.0.1:5003/oauth/callback', TRUE),
	(NOW(), NOW(), 1, 'git.sr.ht', 'git', '$client_secret', '3387e161',
		'http://127.0.0.1:5001/oauth/callback', TRUE);
		'http://127.0.0.1:5001/oauth/callback', TRUE),
	(NOW(), NOW(), 1, 'paste.sr.ht', 'paste', '$client_secret', '3387e161',
		'http://127.0.0.1:5011/oauth/callback', TRUE);
EOF

createdb todo.sr.ht
@@ -33,3 +35,6 @@ psql -d todo.sr.ht </data/todo.sr.ht.sql

createdb git.sr.ht
psql -d git.sr.ht </data/git.sr.ht.sql

createdb paste.sr.ht
psql -d paste.sr.ht </data/paste.sr.ht.sql

base-commit: 8a9a612315c905d59b7d31bbc956a02a3e1cdf75
-- 
2.43.0
Pushed, thanks!