-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #740 from Shelf-nu/standalone-docker
Standalone docker
- Loading branch information
Showing
8 changed files
with
183 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: 🐳 Create and publish a Docker image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
|
||
permissions: | ||
actions: write | ||
contents: read | ||
packages: write | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build: | ||
name: 🐳 Build | ||
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 🛑 Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
|
||
- name: ⬇️ Checkout repo | ||
uses: actions/[email protected] | ||
|
||
- name: 🥡 Set up QEMU | ||
uses: docker/[email protected] | ||
|
||
- name: ✖️ Set up Docker Buildx | ||
uses: docker/[email protected] | ||
|
||
- name: ⚡️ Cache Docker layers | ||
uses: actions/[email protected] | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: 👋 Log in to the Container registry | ||
uses: docker/[email protected] | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: 🧪 Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/[email protected] | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | ||
type=ref,enable=${{ github.ref_type != 'tag' }},suffix=-{{sha}},event=branch | ||
type=ref,event=tag | ||
- name: 🛠 Build and push Docker image | ||
uses: docker/[email protected] | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
# Note: provenance fixes unknown/unknown platform to be generated on build | ||
# https://github.com/orgs/community/discussions/45969#discussioncomment-8170787 | ||
# https://github.com/docker/build-push-action/issues/820#issuecomment-1445131521 | ||
provenance: false | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} | ||
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} | ||
COMMIT_SHA=${{ github.sha }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new | ||
|
||
- name: 🚚 Move cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# https://github.com/Koenkk/zigbee2mqtt/blob/fe0742a628fb782692f9679367e2ab1b11139dd6/.github/workflows/ghcr_cleanup.yml | ||
|
||
name: 🧹 ghcr.io Cleanup | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
actions: write | ||
contents: read | ||
packages: write | ||
|
||
env: | ||
PACKAGE_NAME: shelf.nu | ||
PER_PAGE: 2000 | ||
|
||
jobs: | ||
clean: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: 🗑 Delete untagged images | ||
uses: actions/[email protected] | ||
with: | ||
script: | | ||
const response = await github.request("GET /user/packages/container/${{ env.PACKAGE_NAME }}/versions", | ||
{ per_page: ${{ env.PER_PAGE }} | ||
}); | ||
for(version of response.data) { | ||
if (version.metadata.container.tags.length == 0) { | ||
try { | ||
console.log("delete " + version.id) | ||
const deleteResponse = await github.request("DELETE /user/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { }); | ||
console.log("status " + deleteResponse.status) | ||
} catch (e) { | ||
console.log("failed") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Docker | ||
|
||
If you prefer using docker for running shelf locally or self hosting your live app, we have a Docker image ready for you thanks to [@anatolinicolae](https://github.com/anatolinicolae) | ||
|
||
## Instructions | ||
|
||
1. Make sure you have docker installed on your machine | ||
2. Use the docker run command and replace your env varibales: | ||
|
||
```sh | ||
docker run -d \ | ||
--name "shelf" \ | ||
-e "DATABASE_URL=postgres://{USER}:{PASSWORD}@{HOST}:6543/{DB_NAME}?pgbouncer=true" \ | ||
-e "DIRECT_URL=postgres://{USER}:{PASSWORD}@{HOST}:5432/{DB_NAME}" \ | ||
-e 'SUPABASE_ANON_PUBLIC=ANON_PUBLIC' \ | ||
-e 'SUPABASE_SERVICE_ROLE=SERVICE_ROLE' \ | ||
-e 'SUPABASE_URL=https://{YOUR_INSTANCE_NAME}.supabase.co' \ | ||
-e 'SESSION_SECRET=super-duper-s3cret' \ | ||
-e 'SERVER_URL=http://localhost:3000' \ | ||
-e 'MAPTILER_TOKEN=maptiler-token' \ | ||
-e 'SMTP_HOST=mail.example.com' \ | ||
-e '[email protected]' \ | ||
-e 'SMTP_PWD=super-safe-passw0rd' \ | ||
-p 3000:8080 \ | ||
--restart unless-stopped \ | ||
ghcr.io/Shelf-nu/shelf.nu:latest | ||
``` | ||
|
||
### ARM processors | ||
|
||
You can also run shelf on ARM64 processors. | ||
|
||
1. Linux / Pine A64 | ||
|
||
```shell | ||
root@DietPi:~# | ||
docker run -it --rm --entrypoint /usr/bin/uname ghcr.io/thundersquared/shelf:latest -a | ||
Linux 77ae434f8fe9 6.1.63-current-sunxi64 #1 SMP Mon Nov 20 10:52:19 UTC 2023 aarch64 GNU/Linux | ||
``` | ||
|
||
2. MacOS / M1 Max | ||
|
||
```shell | ||
❯ ~ | ||
docker run -it --rm --platform linux/arm64 --entrypoint /usr/bin/uname ghcr.io/thundersquared/shelf:latest -a | ||
Linux 7a9dff819847 6.5.13-orbstack-00122-g57b8027e2387 #1 SMP Tue Feb 6 07:48:26 UTC 2024 aarch64 GNU/Linux | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
#!/bin/sh -ex | ||
|
||
# This file is how Fly starts the server (configured in fly.toml). Before starting | ||
# the server though, we need to run any prisma migrations that haven't yet been | ||
# run, which is why this file exists in the first place. | ||
# Learn more: https://community.fly.io/t/sqlite-not-getting-setup-properly/4386 | ||
|
||
set -ex | ||
npm run start |