diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3c6c169 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +.git +.github + +Dockerfile +cache.json +settings.json +run.sh + +logs +supplementary +tmp + +README.md diff --git a/.github/workflows/autobuild-workflow.yml b/.github/workflows/autobuild-workflow.yml new file mode 100644 index 0000000..c2cf88f --- /dev/null +++ b/.github/workflows/autobuild-workflow.yml @@ -0,0 +1,25 @@ +name: Autobuild for Docker + +on: + push: + branches: master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Install builder plugin + id: buildx + uses: crazy-max/ghaction-docker-buildx@v3 + with: + buildx-version: latest + qemu-version: latest + - name: Login to Docker + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + - name: Build the image + run: | + docker buildx build --push \ + --tag "${{secrets.DOCKER_TAG}}" \ + --platform linux/amd64,linux/arm/v7 . diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f5a38e5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM python:rc-alpine + +ENV SHELL /bin/sh +ENV LANG C.UTF-8 + +ENV PYTHONUNBUFFERED 1 +ENV PIP_DISABLE_PIP_VERSION_CHECK 1 +ENV PIP_NO_CACHE_DIR 0 + +COPY . /srv +WORKDIR /srv + +RUN \ +# Create user + addgroup -g 423 -S pkgcollector \ + && adduser -u 423 -S pkgcollector -G pkgcollector \ +# Upgrade system + && apk update \ + && apk upgrade --no-cache \ + && apk add --no-cache dpkg gnupg gzip fakeroot xz tar \ +# Install Python dependencies + && pip install --no-cache --upgrade -r requirements.txt \ + && chown -R pkgcollector:pkgcollector . \ +# Cleanup + && rm -rf /tmp/* /var/cache/apk/* + +USER pkgcollector +ENTRYPOINT ["python", "-m", "pkgcollector.Main"] diff --git a/pkgcollector/Main.py b/pkgcollector/Main.py index fb13b04..ccca969 100644 --- a/pkgcollector/Main.py +++ b/pkgcollector/Main.py @@ -54,19 +54,5 @@ def saveSettings(self): json.dump(self.settings, file, sort_keys=True, indent=4, separators=(',', ': ')) if __name__ == '__main__': - def get_lock(process_name): - get_lock._lock_socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) - - try: - get_lock._lock_socket.bind('\0' + process_name) - except socket.error: - print('Program is already running!') - sys.exit() - - if os.geteuid() != 0: - print('Please run this program as root!') - sys.exit() - - get_lock('PackageCollector') main = Main() main.runAllBuilds() diff --git a/requirements.txt b/requirements.txt index bcb6bd8..edb3b29 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -bs4 +beautifulsoup4 deb-pkg-tools python-gnupg requests