Skip to content

Commit

Permalink
added container build
Browse files Browse the repository at this point in the history
  • Loading branch information
clragon authored Dec 1, 2023
1 parent 5471a16 commit 3a0909e
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 3 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ jobs:
name: app_${{ env.file_arch }}
path: build/app_${{ env.file_arch }}

- name: build docker image
run: |
docker buildx create --name builder --use
docker buildx build \
--platform ${{ matrix.arch }} \
-t swan:${{ github.run_id }}-${{ env.file_arch }} \
-t swan:latest \
--build-arg ARCH=${{ matrix.arch }} \
--build-arg BINARY=build/app_${{ env.file_arch }} \
-f Dockerfile . \
--output type=docker,dest=app_image_${{ env.file_arch }}.tar
env:
DOCKER_BUILDKIT: 1

- name: upload docker image artifact
uses: actions/upload-artifact@v3
with:
name: app_image_${{ env.file_arch }}
path: app_image_${{ env.file_arch }}.tar

create-release:
needs: build
runs-on: ubuntu-latest
Expand All @@ -76,6 +96,8 @@ jobs:
uses: softprops/action-gh-release@v1
with:
tag_name: release-${{ github.run_id }}
files: ./app_*/app_*
files: |
./app_*/app_*
./app_image_*/app_image_*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
.vscode
logs
build
database.sqlite3

# app data
config/
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ARG ARCH
FROM --platform=$ARCH ubuntu
RUN apt-get update && apt-get install -y libsqlite3-dev
ARG BINARY
COPY $BINARY /app
ENTRYPOINT ["/app"]
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,35 @@ You can also specify a custom prefix for the bot:
```yml
BOT_PREFIX=your_prefix_here # default: .
```

## Docker

You can run the bot in a Docker container.
A pre-built image is available in the releases section.

To run your image, load the image:

```sh
docker load -i app_image_*.tar
```

then create a docker compose file with the following content:

```yml
version: "3.8"
services:
swan:
image: swan:latest
volumes:
- ./.env:/.env
- config:/config

volumes:
config:
```
Then, run:
```sh
docker compose up -d
```
2 changes: 1 addition & 1 deletion lib/plugins/database/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ part 'database.g.dart';
class SwanDatabase extends _$SwanDatabase {
SwanDatabase()
: super(
NativeDatabase.createInBackground(File('database.sqlite3')),
NativeDatabase.createInBackground(File('config/database.sqlite3')),
);

@override
Expand Down

0 comments on commit 3a0909e

Please sign in to comment.