Skip to content

Commit

Permalink
build: improve non-root user creation in dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobLichterfeld committed Mar 16, 2024
1 parent f1ae5b9 commit ea32b5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

### Enhancements

- build: improve non-root user creation in dockerfile

### Bug Fixes

fix: Subscription to teslamate_topic_update_version added
Expand Down
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV PYTHONDONTWRITEBYTECODE 1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1

# install the OS build deps
# Install the application dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libffi-dev \
Expand All @@ -17,21 +17,21 @@ RUN apt-get update && apt-get install -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Update pip
# Upgrade pip
RUN python -m pip install --upgrade pip

# Copy requirements.txt and install requirements
# Install the application dependencies
WORKDIR /requirements
COPY src/requirements.txt .
RUN python -m pip install -r requirements.txt

# Copy the rest of the code
# Copy the application code
WORKDIR /app
COPY . /app

# Switching to a non-root user, please refer to https://aka.ms/vscode-docker-python-user-rights
RUN useradd appuser && chown -R appuser /app
# Creates a non-root user to run the application and adds permission to access the /app folder
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser

# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
# Run the application
CMD ["python", "./src/teslamte_telegram_bot.py"]

0 comments on commit ea32b5b

Please sign in to comment.