diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 67cde92..bd686ef 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -3,11 +3,11 @@ name: Create and publish a Docker image on: push: - branches: ["docker"] + branches: ["main"] env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + IMAGE_NAME: surfscz/sram-plsc jobs: build-and-push-image: diff --git a/Dockerfile b/Dockerfile index 9a31bde..9fc7443 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,35 @@ -ARG PYTHON_VERSION=3.11-alpine +FROM python:3.8-slim-bookworm -FROM python:${PYTHON_VERSION} +# Do an initial clean up and general upgrade of the distribution +ENV DEBIAN_FRONTEND noninteractive +RUN apt clean && apt autoclean && apt update +RUN apt -y upgrade && apt -y dist-upgrade -RUN apk add py3-virtualenv py3-pytest python3-dev gcc musl-dev openldap-dev bash +# Install the packages we need +RUN apt install -y build-essential libldap2-dev libsasl2-dev git -ENV VENV /.venv -RUN virtualenv ${VENV} -ENV PATH ${VENV}/bin:$PATH +# Clean up +RUN apt autoremove -y && apt clean && apt autoclean && rm -rf /var/lib/apt/lists/* -RUN adduser -D user +RUN mkdir -p /opt/plsc -WORKDIR /app +# Set the default workdir +WORKDIR /opt/plsc +# Create pyff dir +#RUN virtualenv /opt/pyff +# RUN git clone -b main https://github.com/SURFscz/plsc.git /opt/plsc ADD . . -RUN chown -R user:user ${VENV} . -USER user +# Copy process script +COPY misc/process.sh /opt/plsc/process.sh +RUN chmod 755 /opt/plsc/process.sh -RUN pip install --upgrade pip RUN pip install -r requirements.txt -CMD ["./run.sh"] \ No newline at end of file +# Copy entrypoint +COPY misc/entrypoint.sh /entrypoint.sh +RUN chmod 755 /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["/opt/plsc/process.sh"] diff --git a/misc/entrypoint.sh b/misc/entrypoint.sh new file mode 100644 index 0000000..a11e294 --- /dev/null +++ b/misc/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# Do things we need to do before running CMD + +# Hand off to the CMD +exec $@ diff --git a/misc/process.sh b/misc/process.sh new file mode 100644 index 0000000..0a1c05e --- /dev/null +++ b/misc/process.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e +while true +do + sleep 5m + /opt/plsc/run.sh plsc.yml +done + +exit 0