forked from nh-server/Kurisu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes for Docker support (nh-server#832)
* Changes for Docker support This makes a few additions and changes for Kusisu to run inside a Docker container. * config.ini and channels.ini are now in data/ instead of the project root * New GitHub Workflow that builds the image and pushes it to Docker Hub at https://hub.docker.com/repository/docker/nhserver/kurisu There's also commands to pull the image on the server but it's disabled for now. * Uses environment variables to get the commit sha and branch instead of calling git, since Kurisu won't be running from a git repository inside the container. * Disables pull when inside a container for the same reason. * requirements.txt specifies exact versions now. This is useful for build caching when built locally, but also prevents unexpected changes in these libraries. * cogs.events: remove unused import * Push image to ghcr.io instead of Docker Hub Signed-off-by: Ian Burgwin <[email protected]>
- Loading branch information
Showing
11 changed files
with
136 additions
and
33 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,7 @@ | ||
data | ||
.git | ||
.dockerignore | ||
Dockerfile | ||
config.ini | ||
config.ini.example | ||
dockerbuild.sh |
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,58 @@ | ||
name: 'ci' | ||
|
||
on: | ||
push: | ||
branches: port | ||
|
||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
# github username and personal access token | ||
registry: ghcr.io | ||
username: ${{ secrets.CR_USERNAME }} | ||
password: ${{ secrets.CR_PAT }} | ||
- name: Build Docker image | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/amd64 | ||
push: false | ||
# Can't auto-push with v2 right now... | ||
tags: ghcr.io/nh-server/kurisu:latest | ||
build-args: COMMIT=${{ github.sha }},BRANCH=${{ github.ref }} | ||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} | ||
- name: Push Docker image | ||
run: docker push ghcr.io/nh-server/kurisu:latest | ||
# https://stackoverflow.com/questions/60477061/github-actions-how-to-deploy-to-remote-server-using-ssh/60479844#60479844 | ||
# - name: Create SSH key | ||
# run: | | ||
# mkdir -p ~/.ssh/ | ||
# chmod 700 ~/.ssh/ | ||
# echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa | ||
# chmod 600 ~/.ssh/id_rsa | ||
# echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts | ||
# shell: bash | ||
# env: | ||
# SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | ||
# SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }} | ||
# - name: Pull on server | ||
# run: docker-compose pull | ||
# env: | ||
# DOCKER_HOST: ${{ secrets.SSH_HOST }} | ||
# - name: Run on server | ||
# run: docker-compose up -d | ||
# env: | ||
# DOCKER_HOST: ${{ secrets.SSH_HOST }} |
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,5 +1,6 @@ | ||
*.ini | ||
*.sh | ||
!dockerbuild.sh | ||
*.log | ||
*.json | ||
*.png | ||
|
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,15 @@ | ||
FROM python:3.8.5-slim-buster | ||
LABEL org.opencontainers.image.source https://github.com/nh-server/Kurisu | ||
ENV HOME /home/kurisu | ||
RUN useradd -m -d $HOME -s /bin/sh -u 2849 kurisu | ||
WORKDIR $HOME | ||
COPY ./requirements.txt . | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
ENV IS_DOCKER=1 | ||
ARG COMMIT="unknown" | ||
ARG BRANCH="unknown" | ||
ENV COMMIT_SHA=${COMMIT} | ||
ENV COMMIT_BRANCH=${BRANCH} | ||
USER kurisu | ||
COPY --chown=2849:2849 . . | ||
CMD ["python3", "kurisu.py"] |
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
File renamed without changes.
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,7 @@ | ||
version: "3.8" | ||
services: | ||
kurisu: | ||
image: "ghcr.io/nh-server/kurisu" | ||
volumes: | ||
- /opt/kurisudata:/home/kurisu/data | ||
restart: always |
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,2 @@ | ||
#!/bin/sh | ||
docker build --build-arg COMMIT=$(git rev-parse HEAD) --build-arg BRANCH=$(git rev-parse --abbrev-ref HEAD) -t ghcr.io/nh-server/kurisu . |
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,5 +1,5 @@ | ||
discord.py | ||
aiosqlite3 | ||
Pillow | ||
xkcd | ||
pytz | ||
discord.py==1.4.1 | ||
aiosqlite3==0.3.0 | ||
Pillow==7.2.0 | ||
xkcd==2.4.2 | ||
pytz==2020.1 |