Skip to content

Commit d14a6bc

Browse files
committed
Add simple application
1 parent 07ade9b commit d14a6bc

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

.github/workflows/docker-build.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Docker unsigned
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
workflow_dispatch:
10+
11+
env:
12+
# Use docker.io for Docker Hub if empty
13+
REGISTRY: ghcr.io
14+
# github.repository as <account>/<repo>
15+
IMAGE_NAME: ${{ github.repository }}
16+
17+
jobs:
18+
build:
19+
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
packages: write
24+
# This is used to complete the identity challenge
25+
# with sigstore/fulcio when running outside of PRs.
26+
id-token: write
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v3
31+
32+
# Install the cosign tool except on PR
33+
# https://github.com/sigstore/cosign-installer
34+
- name: Install cosign
35+
if: github.event_name != 'pull_request'
36+
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
37+
with:
38+
cosign-release: 'v2.1.1'
39+
40+
# Workaround: https://github.com/docker/build-push-action/issues/461
41+
- name: Setup Docker buildx
42+
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
43+
44+
# Login against a Docker registry except on PR
45+
# https://github.com/docker/login-action
46+
- name: Log into registry ${{ env.REGISTRY }}
47+
if: github.event_name != 'pull_request'
48+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
49+
with:
50+
registry: ${{ env.REGISTRY }}
51+
username: ${{ github.actor }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
54+
# Extract metadata (tags, labels) for Docker
55+
# https://github.com/docker/metadata-action
56+
- name: Extract Docker metadata
57+
id: meta
58+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
59+
with:
60+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
61+
62+
# Build and push Docker image with Buildx (don't push on PR)
63+
# https://github.com/docker/build-push-action
64+
- name: Build and push Docker image
65+
id: build-and-push
66+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
67+
with:
68+
context: .
69+
push: ${{ github.event_name != 'pull_request' }}
70+
tags: ${{ steps.meta.outputs.tags }}
71+
labels: ${{ steps.meta.outputs.labels }}
72+
cache-from: type=gha
73+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:3.8-slim
2+
3+
WORKDIR /app
4+
5+
COPY . /app
6+
7+
RUN pip install --no-cache-dir Flask
8+
9+
EXPOSE 80
10+
11+
CMD ["python", "./app.py"]

app.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from flask import Flask
2+
3+
app = Flask(__name__)
4+
5+
@app.route('/')
6+
def hello():
7+
return "Hello, World!"

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Flask

0 commit comments

Comments
 (0)