Skip to content

Commit

Permalink
ci: setup ci docker build and push
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelgautier committed Jun 23, 2024
1 parent 64062b3 commit d646802
Show file tree
Hide file tree
Showing 13 changed files with 721 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
list-dockerfiles:
runs-on: ubuntu-latest

outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

steps:
- uses: actions/checkout@v4

- id: set-matrix
run: echo "matrix=$(find . -type f -name 'Dockerfile' -exec dirname {} \; | sort -u | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT

docker-build:
needs: list-dockerfiles
runs-on: ubuntu-latest

permissions:
packages: write

strategy:
fail-fast: false
matrix:
dockerfile: ${{ fromJson(needs.list-dockerfiles.outputs.matrix) }}

steps:
- uses: actions/checkout@v4

- name: Create Docker Image name
id: create-image-name
run: echo "image=ghcr.io/emmanuelgautier/awesome-dockerfiles/$(echo ${{ matrix.dockerfile }} | awk -F'/' '{print $NF}'):latest" >> $GITHUB_OUTPUT

- 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.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.dockerfile }}
push: ${{ github.ref == 'refs/heads/main' }}
tags: ${{ steps.create-image-name.outputs.image }}
cache-from: type=registry,ref=${{ steps.create-image-name.outputs.image }}
cache-to: type=inline
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions python/fastapi/fastapi-poetry/app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from typing import Union

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}
627 changes: 627 additions & 0 deletions python/fastapi/fastapi-poetry/poetry.lock

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions python/fastapi/fastapi-poetry/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[tool.poetry]
name = "fastapi-poetry"
version = "1.0.0"
description = ""
authors = []

[tool.poetry.dependencies]
python = ">=3.10,<4.0"
fastapi = "0.110.0"
uvicorn = {extras = ["standard"], version = "0.23.2"}

[tool.poetry.group.dev.dependencies]


[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
2 changes: 2 additions & 0 deletions python/fastapi/fastapi-poetry/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
uvicorn[standard]==0.23.0
fastapi==0.103.2

0 comments on commit d646802

Please sign in to comment.