Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
NextFire committed Nov 6, 2023
0 parents commit 7def2b9
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 0 deletions.
138 changes: 138 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: CI

on:
schedule:
- cron: "0 12 * * *"
push:
branches: ["main"]
workflow_dispatch:

permissions:
contents: read
packages: write
id-token: write
actions: write

env:
REGISTRY: ghcr.io

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- owner: DakaraProject
repo: dakara-client-web
branch: master
plateforms: linux/amd64,linux/arm64
- owner: DakaraProject
repo: dakara-server
branch: master
plateforms: linux/amd64,linux/arm64
- owner: odrling
repo: filestash
branch: subs
plateforms: linux/amd64
dockerfile: docker/Dockerfile
- owner: odrling
repo: syncplay
branch: master
plateforms: linux/amd64,linux/arm64
- owner: mesosphere
repo: traefik-forward-auth
branch: master
plateforms: linux/amd64,linux/arm64

env:
REPOSITORY: ${{ matrix.owner }}/${{ matrix.repo }}
IMAGE_NAME: ${{ github.repository_owner }}/${{ matrix.repo }}

runs-on: ubuntu-latest

steps:
- name: Checkout project repository
uses: actions/checkout@v4
with:
repository: ${{ env.REPOSITORY }}
ref: ${{ matrix.branch }}

- name: Check if image already exists
id: check
if: env.REGISTRY == 'ghcr.io'
continue-on-error: true
run: |
GHCR_TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64)
RESP=$(curl -H "Authorization: Bearer $GHCR_TOKEN" https://ghcr.io/v2/${{ env.IMAGE_NAME }}/tags/list)
echo $RESP | jq .tags | grep sha-$(git rev-parse --short HEAD)
- uses: andymckay/[email protected]
if: steps.check.outcome == 'success'

- name: Install cosign
uses: sigstore/cosign-installer@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
context: git
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ matrix.branch }}
type=sha
- name: Checkout containers repository
uses: actions/checkout@v4
with:
path: containers

- name: Apply .diff and set Dockerfile
id: prepare
run: |
DIFF="containers/${{ matrix.repo }}.diff"
if [ -f $DIFF ]; then
echo Applying $DIFF
git apply $DIFF
fi
CUSTOM_DOCKERFILE="containers/${{ matrix.repo }}.Dockerfile"
if [ -f $CUSTOM_DOCKERFILE ]; then
DOCKERFILE=$CUSTOM_DOCKERFILE
elif [ -f ${{ matrix.dockerfile }} ]; then
DOCKERFILE=${{ matrix.dockerfile }}
else
DOCKERFILE=Dockerfile
fi
echo Will use $DOCKERFILE
echo DOCKERFILE=$DOCKERFILE >> $GITHUB_OUTPUT
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
file: ${{ steps.prepare.outputs.DOCKERFILE }}
platforms: ${{ matrix.plateforms }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Sign the published Docker image
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
14 changes: 14 additions & 0 deletions dakara-client-web.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:lts-alpine AS builder
WORKDIR /src
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:lts-alpine
ENV NODE_ENV=production
WORKDIR /app
RUN npm install -g serve
COPY --from=builder /src/build .
EXPOSE 3000
ENTRYPOINT [ "serve", "-s", "." ]
13 changes: 13 additions & 0 deletions dakara-client-web.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/package.json b/package.json
index f16dc7b..ee4afb5 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,7 @@
},
"scripts": {
"start": "react-app-rewired start",
- "build": "react-scripts build",
+ "build": "react-app-rewired build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
15 changes: 15 additions & 0 deletions dakara-server.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.11-slim

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /app

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY dakara_server dakara_server

EXPOSE 8000
ENTRYPOINT [ "dakara_server/manage.py" ]
CMD [ "runserver" ]

0 comments on commit 7def2b9

Please sign in to comment.