Skip to content

Commit

Permalink
pin requirements
Browse files Browse the repository at this point in the history
clean up docker stuff
also includes the fix where the webserver is not able to punlish any
message
  • Loading branch information
Loki-Afro committed Sep 1, 2021
1 parent 897542d commit f1668ba
Show file tree
Hide file tree
Showing 18 changed files with 78 additions and 234 deletions.
17 changes: 6 additions & 11 deletions .github/workflows/build_push_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ on:
- dependabot/*

jobs:
build_and_push_docker:
build_and_push:
runs-on: ubuntu-latest
strategy:
matrix:
service: [ scanfile, scanurl, webserver ]
steps:
- uses: actions/checkout@v2

- name: Docker meta Service Name
id: docker_meta_img
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository }}-${{ matrix.service }}
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch,enable=false,priority=600
type=sha,enable=true,priority=600,prefix=
Expand All @@ -31,23 +29,20 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Build and push ${{ github.repository }}
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile.${{ matrix.service }}
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: ghcr.io/${{ github.repository }}-${{ matrix.service }}:${{ github.sha }}
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
labels: ${{ steps.docker_meta_img.outputs.labels }}

dispatch:
runs-on: ubuntu-latest
needs:
- build_and_push_docker
- build_and_push
steps:
- uses: actions/checkout@v2
- name: Extract branch name
Expand Down
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.7-slim-buster

ENV LC_ALL=C.UTF-8
ENV LANG C.UTF-8

WORKDIR /usr/src/app
COPY requirements.txt setup.py ./
RUN pip3 install .
COPY antivirus_service ./antivirus_service

RUN python3 ./setup.py develop

ENTRYPOINT ["/usr/local/bin/antivirus"]
22 changes: 0 additions & 22 deletions Dockerfile.scanfile

This file was deleted.

23 changes: 0 additions & 23 deletions Dockerfile.scanfile.20191118

This file was deleted.

18 changes: 0 additions & 18 deletions Dockerfile.scanfile.alpine

This file was deleted.

22 changes: 0 additions & 22 deletions Dockerfile.scanurl

This file was deleted.

23 changes: 0 additions & 23 deletions Dockerfile.scanurl.20191118

This file was deleted.

22 changes: 0 additions & 22 deletions Dockerfile.webserver

This file was deleted.

23 changes: 0 additions & 23 deletions Dockerfile.webserver.20191118

This file was deleted.

3 changes: 1 addition & 2 deletions ansible/group_vars/all/antivirus_check_service.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
ANTIVIRUS_WEBSERVER_IMAGE_NAME: ghcr.io/hpi-schul-cloud/antivirus_check_service-webserver
ANTIVIRUS_SCANFILE_IMAGE_NAME: ghcr.io/hpi-schul-cloud/antivirus_check_service-scanfile
ANTIVIRUS_IMAGE_NAME: ghcr.io/hpi-schul-cloud/antivirus_check_service
ANTIVIRUS_PORT: 8080

Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ spec:
runAsNonRoot: true
containers:
- name: antivirus-scanfile
image: {{ ANTIVIRUS_SCANFILE_IMAGE_NAME }}:{{ APP_IMAGE_TAG }}
image: {{ ANTIVIRUS_IMAGE_NAME }}:{{ APP_IMAGE_TAG }}
imagePullPolicy: IfNotPresent
args: ["scan-file"]
envFrom:
- secretRef:
name: antivirus-secret
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ spec:
runAsNonRoot: true
containers:
- name: antivirus-webserver
image: {{ ANTIVIRUS_WEBSERVER_IMAGE_NAME }}:{{ APP_IMAGE_TAG }}
image: {{ ANTIVIRUS_IMAGE_NAME }}:{{ APP_IMAGE_TAG }}
imagePullPolicy: IfNotPresent
args: ["webserver"]
ports:
- name: antivirus-web
containerPort: {{ ANTIVIRUS_PORT }}
Expand Down
13 changes: 8 additions & 5 deletions antivirus_service/service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
import os
import sys
import yaml
import click
import logging

Expand All @@ -17,7 +15,7 @@ def __init__(self, env, debug):
self.env = env
self.project_root = os.path.dirname(os.path.abspath(__file__))
self.config = {}

env = Env()
with env.prefixed(self.env.upper()+"_"):
self.config[self.env]={}
Expand Down Expand Up @@ -49,7 +47,7 @@ def __init__(self, env, debug):
self.config[self.env][param]['scan_url']['queue']=env("QUEUE","scan_url")
self.config[self.env][param]['scan_url']['routing_key']=env("ROUTING_KEY","scan_url")

loglevel = logging.INFO if debug else logging.ERROR
loglevel = logging.INFO if debug else logging.ERROR
logging.basicConfig(level=loglevel)


Expand Down Expand Up @@ -96,5 +94,10 @@ def webserver(ctx):
except KeyboardInterrupt:
webserver.stop()


def main():
cli(obj={})
cli(obj={})


if __name__ == "__main__":
main()
Loading

0 comments on commit f1668ba

Please sign in to comment.