Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper user permission for container #45

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@ LABEL org.opencontainers.image.authors="dev@shoobx.com"


RUN apt-get update && \
apt-get upgrade -y &&\
apt-get upgrade -y vim && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*

ARG APP_USER=shoobx\
APP_GROUP=shoobx\
ARG APP_USER=shoobx \
APP_GROUP=shoobx \
CODE_FOLDER=/shoobx/shoobx.mocks3 \
USER_ID=2000 \
GROUP_ID=2000

ENV APP_HOME=/home/$APP_USER
RUN groupadd --gid $GROUP_ID --non-unique $APP_GROUP && \
useradd --no-log-init --uid $USER_ID --non-unique --gid $GROUP_ID --create-home --shell /bin/bash $APP_USER && \
echo Created user $USER_ID and group $GROUP_ID

USER $APP_USER
WORKDIR $CODE_FOLDER

COPY . .
COPY --chown=$APP_USER:$APP_GROUP . .
ENV PATH="$PATH:$APP_HOME/.local/bin"

RUN pip install -r requirements.txt

USER $APP_USER

CMD sbx-mocks3-serve
CMD ["sbx-mocks3-serve"]
18 changes: 17 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,21 @@ Shoobx Mock S3 Server
:alt: Maintainability

This package implements a mock S3 server including bucket shadowing
support. The code is based on the `moto` package by implementing a custom
support. The code is based on the ``moto`` package by implementing a custom
service.

Configure Docker image with environment variables
-------------------------------------------------

If you want to change variable from config use next patter ``{section}_{name}_{variable}.`` For example you want to change directory for ``shoobx:mocks3`` section::

[shoobx:mocks3]
log-level = INFO
directory = ./data

[bar:boo]
baz = foo

To change it use ``SHOOBX_MOCKS3_DIRECTORY=/some/path/to/folder``.

For ``baz`` accordingly ``BAR_BOO_BAZ=MyValue``
4 changes: 3 additions & 1 deletion src/shoobx/mocks3/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def fill_config(config_path):

for section in config.sections():
for key in config[section]:
os_key = key.upper().replace('-', '_')
env_section = section.upper().replace(':', '_')
env_key = key.upper().replace('-', '_')
os_key = f"{env_section}_{env_key}"
if os_key in os.environ:
config[section][key] = os.environ[os_key]
return config
Expand Down
2 changes: 1 addition & 1 deletion src/shoobx/mocks3/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_configure_override_by_env(self):
app_config = config.load_config(config_path)

self.assertEqual(app_config["shoobx:mocks3"]["log-level"], "INFO")
with mock.patch.object(os, "environ", {"LOG_LEVEL": "ERROR"}):
with mock.patch.object(os, "environ", {"SHOOBX_MOCKS3_LOG_LEVEL": "ERROR"}):
config._CONFIG = None
app_config = config.load_config(config_path)
self.assertEqual(app_config["shoobx:mocks3"]["log-level"], "ERROR")
Loading