diff --git a/project-ml-microservice-kubernetes/Dockerfile b/project-ml-microservice-kubernetes/Dockerfile index 8f70001b57..166d1b7d64 100644 --- a/project-ml-microservice-kubernetes/Dockerfile +++ b/project-ml-microservice-kubernetes/Dockerfile @@ -2,17 +2,21 @@ FROM python:3.7.3-stretch ## Step 1: # Create a working directory +WORKDIR /app ## Step 2: # Copy source code to working directory +COPY . /app ## Step 3: # Install packages from requirements.txt +RUN pip install --no-cache-dir --trusted-host pypi.python.org -r requirements.txt # hadolint ignore=DL3013 ## Step 4: # Expose port 80 +EXPOSE 80 ## Step 5: # Run app.py at container launch - +CMD ["python", "app.py"] diff --git a/project-ml-microservice-kubernetes/Makefile b/project-ml-microservice-kubernetes/Makefile index 759f77a425..86d7a95bb7 100644 --- a/project-ml-microservice-kubernetes/Makefile +++ b/project-ml-microservice-kubernetes/Makefile @@ -11,6 +11,9 @@ setup: python3 -m venv ~/.devops install: + # Some necessary files for Scipy to work for Ubuntu + # sudo apt install libblas3 liblapack3 liblapack-dev libblas-dev -y + # sudo apt install gfortran -y # This should be run from inside a virtualenv pip install --upgrade pip &&\ pip install -r requirements.txt @@ -22,6 +25,8 @@ test: lint: # See local hadolint install instructions: https://github.com/hadolint/hadolint + wget -O /bin/hadolint https://github.com/hadolint/hadolint/releases/download/v2.10.0/hadolint-Linux-x86_64 + chmod +x /bin/hadolint # This is linter for Dockerfiles hadolint Dockerfile # This is a linter for Python source code linter: https://www.pylint.org/ diff --git a/project-ml-microservice-kubernetes/run_docker.sh b/project-ml-microservice-kubernetes/run_docker.sh index 65c3f832e4..a29b68f2af 100755 --- a/project-ml-microservice-kubernetes/run_docker.sh +++ b/project-ml-microservice-kubernetes/run_docker.sh @@ -4,9 +4,13 @@ # Step 1: # Build image and add a descriptive tag +docker build --tag=ml-kub-project . # Step 2: # List docker images +docker image ls # Step 3: -# Run flask app +# Run flask app with logging local and to a file +docker run -p 8000:80 ml-kub-project +# docker run --log-driver local --log-opt max-size=10m --log-opt max-file=3 -p 8000:80 ml-kub-project