-
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
Lucas Maurice
committed
Feb 4, 2024
1 parent
4c4f438
commit b383a40
Showing
2 changed files
with
118 additions
and
0 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,53 @@ | ||
name: Deploy Images to GHCR | ||
|
||
env: | ||
IMAGE_NAME: ghcr.io/justereseau/sonarr | ||
|
||
on: | ||
workflow_dispatch: | ||
# schedule: | ||
# - cron: "45 6 * * *" | ||
push: | ||
branches: | ||
- main | ||
- implement_v4 | ||
paths-ignore: | ||
- README.md | ||
- LICENSE | ||
|
||
jobs: | ||
sonarr_v4_stable: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout GitHub Action | ||
uses: actions/checkout@main | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Read latest release | ||
id: get_latest_release | ||
run: | | ||
echo "RELEASE_DATA=$(curl -s https://services.sonarr.tv/v1/releases | jq -c '.\"v4-stable\" | {tag: .version, assets: .linuxMusl | map_values(.archive)}')" >> "$GITHUB_ENV" | ||
shell: bash | ||
|
||
- name: Extract data from JSON response | ||
id: extract_data | ||
run: | | ||
echo "release=$(echo $RELEASE_DATA | jq -r '.tag')" >> "$GITHUB_OUTPUT" | ||
shell: bash | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./v4 | ||
file: ./Dockerfile | ||
push: true | ||
build-args: | | ||
RELEASE_TAG=${{ steps.extract_data.outputs.release }} | ||
RELEASE_DATA=${{ steps.get_latest_release.outputs.release_data }} | ||
tags: ${{ env.IMAGE_NAME }}:latest,${{ env.IMAGE_NAME }}:${{ steps.extract_data.outputs.release }} |
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,65 @@ | ||
FROM alpine:latest as builder | ||
|
||
# Read the release version from the build args | ||
ARG RELEASE_TAG | ||
ARG RELEASE_DATA | ||
ARG TOOL_NAME | ||
|
||
# Set the working directory | ||
WORKDIR /build | ||
|
||
# Install the build dependencies | ||
RUN apk update && apk upgrade && apk add --no-cache jq curl | ||
|
||
# Get the download URL | ||
RUN case $(uname -m) in \ | ||
x86_64) \ | ||
echo ${RELEASE_DATA} | jq -c '.assets.x64' > /tmp/release_data.json \ | ||
;; \ | ||
aarch64) \ | ||
echo ${RELEASE_DATA} | jq -c '.assets.arm64' > /tmp/release_data.json \ | ||
;; \ | ||
*) \ | ||
echo "Unsupported architecture > $(uname -m)" \ | ||
exit 1 \ | ||
;; \ | ||
esac | ||
|
||
# Download and extract the binary | ||
RUN wget -O /tmp/binary.tar.gz $(cat /tmp/release_data.json | jq -r '.url') && \ | ||
echo "$(cat /tmp/release_data.json | jq -r .hash ) /tmp/binary.tar.gz" | sha256sum -c - && \ | ||
tar -xvzf /tmp/binary.tar.gz -C /build --strip-components=1 && \ | ||
rm -rf /build/Sonarr.Update | ||
|
||
# Write a launch script | ||
RUN echo "#!/bin/sh" > /build/launch.sh && \ | ||
echo "/bin/${TOOL_NAME} -nobrowser -data=/config" >> /build/launch.sh && \ | ||
chmod +x /build/launch.sh | ||
|
||
FROM alpine:latest | ||
|
||
LABEL build="JusteReseau - Version: ${RELEASE_TAG}" | ||
LABEL org.opencontainers.image.description="This is a docker image for ${TOOL_NAME}, that work with Kubernetes security baselines." | ||
LABEL org.opencontainers.image.licenses="WTFPL" | ||
LABEL org.opencontainers.image.source="https://github.com/justereseau/Servarr" | ||
LABEL maintainer="JusteSonic" | ||
|
||
COPY --from=builder /build /bin | ||
|
||
# Install runtime dependencies | ||
RUN apk add --no-cache libintl sqlite-libs icu-libs && rm -rf /var/cache/apk/* | ||
|
||
# Ensure the Servarr user and group exists and set the permissions | ||
RUN adduser -D -u 1000 -h /config servarr \ | ||
&& mkdir -p /config \ | ||
&& chown -R servarr:servarr /config \ | ||
&& chown -R servarr:servarr /bin | ||
|
||
# Set the user | ||
USER servarr | ||
|
||
# Expose the port | ||
EXPOSE 8989 | ||
|
||
# Set the command | ||
CMD ["/bin/launch.sh"] |