Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/paste-server-rs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
- 'paste-server-rs/**'
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: aosc-dev/paste-server-rs

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -47,3 +51,41 @@ jobs:
with:
name: paste-server-rs
path: paste-server-rs/target/release/paste-server-rs

build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: "{{defaultContext}}:paste-server-rs"
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v3
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

5 changes: 5 additions & 0 deletions paste-server-rs/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
compose.yml
contents
target
test
.env
13 changes: 13 additions & 0 deletions paste-server-rs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM rust:1-alpine AS builder

WORKDIR /app
RUN apk add --no-cache musl-dev
COPY . .
RUN cargo build --release

FROM alpine:latest AS runner

WORKDIR /app
COPY --from=builder /app/target/release/paste-server-rs .
EXPOSE 2334
CMD ["./paste-server-rs"]
30 changes: 30 additions & 0 deletions paste-server-rs/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
services:
app:
build: .
container_name: paste-server-rs
depends_on:
- db
ports:
- "127.0.0.1:2334:2334"
volumes:
- contents:/app/contents
environment:
- PASTE_LISTEN_ADDRESS=0.0.0.0:2334
- DATABASE_URL=postgresql://postgres:password@db/paste
- PASTE_DB_ADDRESS=postgresql://postgres:password@db/paste
- PASTE_FILE_DIR=/app/contents
- PUBLIC_PASTE_URL=http://localhost:2334

db:
image: postgres:17
container_name: paste-db
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
- POSTGRES_DB=paste

volumes:
postgres_data:
contents: