forked from jagrosh/MusicBot
-
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.
- Loading branch information
Showing
6 changed files
with
175 additions
and
8 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,84 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
branches: | ||
- "master" | ||
- "feature/docker" | ||
- "translation/chinese" | ||
|
||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get repo name | ||
id: repo_name | ||
run: | | ||
echo "name=$(ghcr.io/${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | ||
- name: Get Docker Tag | ||
id: docker_tag | ||
run: | | ||
if [[ "${GITHUB_REF}" == refs/heads/*/* ]]; then | ||
echo "tag=$(${GITHUB_REF} | awk -F/ '{print $NF}')" >> $GITHUB_OUTPUT | ||
else | ||
echo "tag=$(${GITHUB_REF} | sed 's/refs\/heads\///')" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Docker Setup Qemu | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Docker Setup Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Docker Login | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.CR_PAT }} | ||
|
||
- name: Docker Cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Docker Metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ steps.repo_name.outputs.name }} | ||
tags: | | ||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }} | ||
type=raw,value= ${{ steps.docker_tag.outputs.tag }},enable=${{ startsWith(github.ref, 'refs/heads/') }} | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=sha | ||
- name: Docker Build and Push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
platforms: | | ||
linux/amd64, | ||
linux/arm64 | ||
cache-from: | | ||
type=local,src=/tmp/.buildx-cache | ||
cache-to: | | ||
type=local,dest=/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# --------------------------------------------- | ||
# Build JDA-Utilities | ||
FROM maven:3.8.6-openjdk-11 AS jda-builder | ||
|
||
WORKDIR /app | ||
|
||
RUN git clone https://github.com/JDA-Applications/JDA-Utilities ./ \ | ||
&& git checkout c16a4b264b7dc492b35e65cb295aec9980d186b2 \ | ||
&& chmod +x ./gradlew \ | ||
&& ./gradlew clean \ | ||
&& ./gradlew build \ | ||
&& ./gradlew publishToMavenLocal | ||
|
||
# --------------------------------------------- | ||
# Build JMusicBot | ||
FROM maven:3.8.5-openjdk-17 AS builder | ||
|
||
WORKDIR /app | ||
ADD . . | ||
|
||
COPY --from=jda-builder /root/.m2/repository /root/.m2/repository | ||
COPY --from=jda-builder /app/build/libs /root/.m2/repository/com/jagrosh/jda-utilities/3.1.0 | ||
|
||
RUN mvn clean | ||
RUN mvn install | ||
|
||
# --------------------------------------------- | ||
# Create final image with only runtime dependencies | ||
FROM debian:12.7-slim | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /app/target/JMusicBot-Snapshot-All.jar /app/JMusicBot.jar | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y openjdk-17-jre-headless \ | ||
&& apt-get install -y locales \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 | ||
|
||
ENV LANG en_US.utf8 | ||
|
||
CMD [ "/usr/bin/java", "-Dnogui=true", "-Dconfig.override_with_env_vars=true", "-jar", "/app/JMusicBot.jar" ] |
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,12 @@ | ||
services: | ||
jagrosh-musicbot: | ||
image: ghcr.io/lynbean/jagrosh-musicbot:latest | ||
container_name: jmusicbot | ||
restart: always | ||
volumes: | ||
- ./data:/app/data | ||
environment: | ||
# https://github.com/jagrosh/MusicBot/wiki/Getting-a-Bot-Token | ||
CONFIG_FORCE_token: BOT_TOKEN_HERE | ||
# https://github.com/jagrosh/MusicBot/wiki/Finding-Your-User-ID | ||
CONFIG_FORCE_owner: 0 |
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