Skip to content
Open
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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.*
*.md
62 changes: 62 additions & 0 deletions .github/workflows/docker-image-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Docker Image CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
inputs:
tags:
description: 'Manual Build'
required: false

jobs:
build-and-push:
runs-on: ubuntu-latest

env:
IMAGE_NAME: python_github_calendar_api

steps:
-
name: Checkout Code
uses: actions/checkout@v4

-
name: Set up QEMU
uses: docker/setup-qemu-action@v3

-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

-
name: Get current datetime for Image Tag
id: datetime
run: echo "::set-output name=tag::$(TZ='Asia/Shanghai' date +'%Y%m%d_%H%M%S')"

-
name: Build and Push Image
uses: docker/build-push-action@v5
with:
context: .
platforms: |
linux/386
linux/amd64
linux/arm/v6
linux/arm/v7
linux/arm64/v8
linux/ppc64le
linux/s390x
push: true
tags: |
${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.datetime.outputs.tag }}
${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
4 changes: 4 additions & 0 deletions .vercelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.*
*.md
__init__.py
Dockerfile
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3-alpine

LABEL name="python_github_calendar_api" \
repository="https://github.com/Zfour/python_github_calendar_api" \
contrubutors="Zfour, ShengQiBaoZao, seeleclover"

ENV TZ=Asia/Shanghai

WORKDIR /usr/src/app

COPY . .
RUN pip install --no-cache-dir -r requirements.txt

CMD [ "python", "-u", "__init__.py" ]
16 changes: 16 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: UTF-8 -*-
from http.server import HTTPServer
from api.index import handler
import logging

logging.basicConfig(
datefmt = '%d/%b/%Y %H:%M:%S',
format = '[%(asctime)s] "%(levelname)s: %(message)s" -',
level=logging.INFO
)

if __name__ == '__main__':
host = ('0.0.0.0', 80)
server = HTTPServer(host, handler)
logging.info("Starting server, listen at http://%s:%s" % host)
server.serve_forever()
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ certifi==2020.12.5
chardet==4.0.0
idna==2.10
requests==2.25.1
urllib3==1.26.2
urllib3==1.26.17