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

Add a github action to build a docker container and push it to ghcr.io #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
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
22 changes: 22 additions & 0 deletions .github/workflows/container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: container
on: [ push ]

jobs:

docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: docker
run: docker build --file Dockerfile --tag ${{ github.REPOSITORY }}:${{ github.SHA }} .
- name: start image
run: docker run --rm -i ${{ github.REPOSITORY }}:${{ github.SHA }}
- name: push the image
uses: mr-smithers-excellent/docker-build-push@v4
with:
tag: ${{ github.SHA }}
image: ${{ github.REPOSITORY }}
registry: ghcr.io
username: ${{ github.ACTOR }} # todo: are packages per repo or per user?!
password: ${{ secrets.PUSHTOKEN }}
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:alpine3.12

RUN pip3 install mysql-connector-python
RUN mkdir /app
COPY syslogserver.py /app/syslogserver.py


CMD [ "python3", "/app/syslogserver.py" ]
4 changes: 4 additions & 0 deletions syslogserver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import socketserver
from datetime import datetime
import time
import sys

import mysql.connector as mariadb

Expand Down Expand Up @@ -110,6 +111,7 @@ def handle(self):
mariadb_connection = mariadb.connect(user = db_user, password = db_password, host = db_host, port = db_port)
except mariadb.Error as error:
print('Error: {}'.format(error))
sys.exit()

#every time a new cursor is created because the old one gets closed
#in the called write_to_db function
Expand Down Expand Up @@ -137,3 +139,5 @@ def handle(self):

#handle requests until explicit shutdown(), see python docs
server.serve_forever()

sys.exit()