Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: setup ci docker build and push #11

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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