Skip to content

Commit

Permalink
optimize dockerfile & update README
Browse files Browse the repository at this point in the history
  • Loading branch information
phoehnel committed Jan 9, 2022
1 parent e45d711 commit 3456f09
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
19 changes: 12 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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" ]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
14 changes: 7 additions & 7 deletions rest-light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

##################################################
Expand Down Expand Up @@ -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)}

##################################################
Expand Down

0 comments on commit 3456f09

Please sign in to comment.