feat: add container

Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
Devin Buhl 2023-12-13 17:15:37 -05:00
parent 5bcdf4fe43
commit 64661f7d5e
No known key found for this signature in database
5 changed files with 159 additions and 0 deletions

23
.editorconfig Normal file
View File

@ -0,0 +1,23 @@
; https://editorconfig.org/
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[{Makefile,go.mod,go.sum,*.go,.gitmodules}]
indent_style = tab
indent_size = 4
[*.md]
indent_size = 4
trim_trailing_whitespace = false
[{Dockerfile,*.bash,*.sh,*.py}]
indent_style = space
indent_size = 4

48
.github/workflows/ci.yaml vendored Normal file
View File

@ -0,0 +1,48 @@
---
name: ci
on:
push:
branches:
- master
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/blacktwin/jbops
tags: |
type=ref,event=branch
type=ref,event=pr
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

52
.github/workflows/release.yaml vendored Normal file
View File

@ -0,0 +1,52 @@
---
name: release
on:
push:
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/blacktwin/jbops
flavor: |
latest=true
prefix=v
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

30
Dockerfile Normal file
View File

@ -0,0 +1,30 @@
FROM python:3.12-alpine
WORKDIR /app
COPY . .
RUN apk add --no-cache \
bash ca-certificates \
&& \
apk add --no-cache --virtual=.build-deps \
build-base \
libffi-dev \
openssl-dev \
musl-dev \
python3-dev \
py3-pip \
&& pip install --upgrade pip \
&& pip install --upgrade --requirement /app/requirements.txt \
&& apk del --purge .build-deps \
&& chown -R root:root /app \
&& chmod -R 755 /app
ENV PLEXAPI_CONFIG_PATH="/config/config.ini" \
JBOPS_SCRIPT_PATH="fun/plexapi_haiku.py"
USER nobody
VOLUME ["/config"]
ENTRYPOINT ["/bin/bash"]
CMD ["/docker-entrypoint.sh"]

6
docker-entrypoint.sh Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
exec \
/usr/bin/python3 \
"/app/${JBOPS_SCRIPT_PATH}" \
"$@"