Skip to content

Commit

Permalink
Rust Rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
Loudbooks authored Dec 12, 2024
2 parents b08a41f + 451ce14 commit 6fceb7e
Show file tree
Hide file tree
Showing 51 changed files with 4,228 additions and 1,148 deletions.
130 changes: 56 additions & 74 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,90 +8,72 @@ on:
- backend/**
branches:
- master

- dev

jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write

strategy:
matrix:
component: [frontend, backend]
steps:
- name: Checkout code
uses: actions/checkout@v3

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 23
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build with Gradle (backend)
run: |
cd backend
./gradlew bootJar
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get Commit Hash
id: get_commit_hash
run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Log in to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push frontend Docker image to GHCR
uses: docker/build-push-action@v3
with:
context: ./frontend
file: ./frontend/Dockerfile
build-args: |
COMMIT_HASH=${{ env.hash }}
push: true
tags: |
ghcr.io/loudbooks/pastebook-frontend:latest
ghcr.io/loudbooks/pastebook-frontend:${{ env.hash }}
- name: Get Commit Hash
id: get_commit_hash
run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Build and push backend Docker image to GHCR
uses: docker/build-push-action@v3
with:
context: ./backend
file: ./backend/Dockerfile
push: true
tags: |
ghcr.io/loudbooks/pastebook-backend:latest
ghcr.io/loudbooks/pastebook-backend:${{ env.hash }}
- name: Set Docker Tags
id: set_tags
run: |
if [ "${{ github.ref_name }}" == "master" ]; then
echo "tag=latest" >> $GITHUB_ENV
elif [ "${{ github.ref_name }}" == "dev" ]; then
echo "tag=dev" >> $GITHUB_ENV
else
echo "Unknown branch: ${{ github.ref_name }}"
exit 1
fi
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push Docker image to GHCR
uses: docker/build-push-action@v3
with:
context: ./${{ matrix.component }}
file: ./${{ matrix.component }}/Dockerfile
build-args: |
COMMIT_HASH=${{ env.hash }}
push: true
tags: |
ghcr.io/loudbooks/pastebook-${{ matrix.component }}:${{ env.tag }}
ghcr.io/loudbooks/pastebook-${{ matrix.component }}:${{ env.hash }}
- name: Build and push frontend Docker image to Docker Hub
uses: docker/build-push-action@v3
with:
context: ./frontend
build-args: |
COMMIT_HASH=${{ env.hash }}
file: ./frontend/Dockerfile
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/pastebook-frontend:latest
${{ secrets.DOCKER_USERNAME }}/pastebook-frontend:${{ env.hash }}
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push backend Docker image to Docker Hub
uses: docker/build-push-action@v3
with:
context: ./backend
file: ./backend/Dockerfile
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/pastebook-backend:latest
${{ secrets.DOCKER_USERNAME }}/pastebook-backend:${{ env.hash }}
- name: Build and push Docker image to Docker Hub
uses: docker/build-push-action@v3
with:
context: ./${{ matrix.component }}
file: ./${{ matrix.component }}/Dockerfile
build-args: |
COMMIT_HASH=${{ env.hash }}
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/pastebook-${{ matrix.component }}:${{ env.tag }}
${{ secrets.DOCKER_USERNAME }}/pastebook-${{ matrix.component }}:${{ env.hash }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.*
!.gitignore
docker-compose.yml
.idea
.idea
/backend/target
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PasteBook
An easy on the eyes, portable, lightning fast pastebin written in Svelte and Kotlin.
An easy on the eyes, portable, lightning fast pastebin written in Svelte and Rust.

### Prerequisites
Docker. Both the frontend and backend are to be installed with Docker. You can learn more [here](https://www.docker.com).
Expand Down Expand Up @@ -73,9 +73,11 @@ systemctl restart nginx
Run the following commands in succession.
```bash
docker compose stop
docker compose pull
docker compose up -d
```

# Final Notes
Wow. There was a lot that can go wrong there. I'm not an expert. If you need help, you can email me at [email protected] or find me elsewhere.

💜
40 changes: 0 additions & 40 deletions backend/.gitignore

This file was deleted.

Loading

0 comments on commit 6fceb7e

Please sign in to comment.