diff --git a/Dockerfile b/Dockerfile index a25d7f9..dbdf84f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,18 +3,17 @@ FROM python:3-slim-buster LABEL authors="Pascal Höhnel" # Arguments from Build-Pipeline to display Version -ARG APP_VERSION -ARG GITHUB_REPOSITORY -ENV APP_VERSION="$APP_VERSION" -ENV GITHUB_REPOSITORY="$GITHUB_REPOSITORY" +ARG APP_VERSION="DEV" +ARG GITHUB_REPOSITORY="uupascal/REST-light" + # Set App-Path and cd ENV APP_PATH="/opt/rest-light" WORKDIR $APP_PATH -# get dependencies +# install dependencies & prepare persistance-folder COPY requirements.txt ./ RUN export BUILD_TOOLS="git make gcc g++" && export WIRINGPI_SUDO="" \ - && mkdir -p /etc/rest-light \ + && mkdir -p /etc/rest-light && chown -R www-data:www-data /etc/rest-light \ && apt-get update \ && apt-get install -y --no-install-recommends $BUILD_TOOLS nginx libstdc++6 libc6 frama-c-base \ && pip install --no-cache-dir -r requirements.txt \ @@ -34,8 +33,14 @@ RUN export BUILD_TOOLS="git make gcc g++" && export WIRINGPI_SUDO="" \ # Copy App COPY . $APP_PATH COPY nginx.conf /etc/nginx -RUN chmod +x ./startup.sh +RUN chmod +x ./startup.sh && chown -R www-data:www-data . + +# persist version variables in correct user +USER www-data +ENV APP_VERSION="$APP_VERSION" +ENV GITHUB_REPOSITORY="$GITHUB_REPOSITORY" +USER root # Run EXPOSE 4242 CMD [ "./startup.sh" ] \ No newline at end of file diff --git a/README.md b/README.md index 5cf6f14..7d7c3c1 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ As the license implies, this software is provided without warranty of any kind. Use the docker tag `latest` to always get the latest stable image. -The images are also tagged with the current date, so to pin to a static version, you can for example use the tag `2022.01.09`. +The images are also tagged with the current timestamp, so to pin to a static version, you can for example use the tag `2022.01.09-1746`. Unstable/Development versions are prefixed with `DEV-` and should only be used for testing purposes. diff --git a/rest-light.py b/rest-light.py index 82372c7..8d93146 100644 --- a/rest-light.py +++ b/rest-light.py @@ -74,9 +74,9 @@ def load_key(): sys.exit() # return key and log - logging.warning('#'*60) - logging.warning('Generated API-Key: ' + new_key) - logging.warning('#'*60) + logging.warning('#'*72) + logging.warning('# Generated API-Key: ' + new_key) + logging.warning('#'*72) return new_key ################################################## @@ -143,17 +143,17 @@ def run_command(arguments): # treat output try: if run_result is not None and run_result.returncode == 0: - logging.debug("Successfully ran command: " + " ".join(arguments)) + logging.info("Successfully ran command: " + " ".join(arguments)) return {'status': 'Success', 'stdout': str(run_result.stdout) } elif run_result is not None and hasattr(run_result, 'stderr'): logging.error( - "Running of subprocess failed with output: " + str(run_result.stderr)) + "Running of command " + " ".join(arguments) + " failed with output: " + str(run_result.stderr)) return {'status': 'Error', 'stdout': str(run_result.stdout), 'stdout': str(run_result.stderr) } else: - logging.error("Running of subprocess failed without output") + logging.error("Running of command " + " ".join(arguments) + " failed without output") return {'status': 'Error', 'stdout': 'Could not run command!'} except BaseException as e: - logging.fatal('Unkown exception when trying to parse subprocess output! ' + str(e)) + logging.fatal('Unkown exception when trying to parse command " + " ".join(arguments) + " output! ' + str(e)) return {'status': 'Error', 'stdout': 'Unkown exception when trying to parse subprocess output! ' + str(e)} ##################################################