Skip to content

Commit

Permalink
Merge pull request #11 from emmanuelgautier/docker-ci-build
Browse files Browse the repository at this point in the history
ci: setup ci docker build and push
  • Loading branch information
emmanuelgautier authored Jun 23, 2024
2 parents 64062b3 + ee2e595 commit 6e02010
Show file tree
Hide file tree
Showing 15 changed files with 1,532 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion rust/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
Expand Down
Loading

0 comments on commit 6e02010

Please sign in to comment.