Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jpflouret committed Mar 19, 2024
0 parents commit 7386da4
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Docker Image CI

on:
schedule:
- cron: '29 15 * * *'
push:
branches: [ "main" ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/[email protected]
with:
cosign-release: 'v2.2.2'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM python:3.9.18-alpine
WORKDIR /app
COPY server.py .
expose 8080/tcp
CMD ["python", "-u", "/app/server.py"]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# teapot

A simple web server that returns http status code 418.
25 changes: 25 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from http.server import BaseHTTPRequestHandler, HTTPServer

bindAddress = ""
serverPort = 8080

class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
self.server_version = 'Teapot/1.0.0'
self.sys_version = 'Coffee/1.0.0'
self.send_response(418)
self.send_header("Content-type", "text/plain; charset=utf-8")
self.end_headers()
self.wfile.write(bytes("I'm a teapot.\n", "utf-8"))

if __name__ == "__main__":
webServer = HTTPServer((bindAddress, serverPort), MyServer)
print("Server listening on %s:%s" % (bindAddress, serverPort))

try:
webServer.serve_forever()
except KeyboardInterrupt:
pass

webServer.server_close()
print("Server stopped.")

0 comments on commit 7386da4

Please sign in to comment.