Add docker and build-push github action.

This commit is contained in:
NMC 2025-01-15 00:36:14 -05:00
parent a0c58601fd
commit db4e3b5100
2 changed files with 63 additions and 0 deletions

48
.github/workflows/docker-build-push.yml vendored Normal file
View file

@ -0,0 +1,48 @@
name: Docker Build and Push
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

15
Dockerfile Normal file
View file

@ -0,0 +1,15 @@
FROM python:3-alpine
RUN apk update && \
apk add --no-cache py3-colorama && \
pip install --no-cache-dir setuptools && \
rm -rf /var/cache/apk/*
WORKDIR /app
COPY . /app
RUN python3 setup.py install
CMD [ "sara", "--config-file", "/config/routeros.rsc" ]