-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch containers to unpriviliged service user (#357)
* Switched container to unpriviliged service user * splitted repo Dockerfiles in variants * updated CI to build both container variants * restructured Dockerfiles and added optional deps * split root and nonroot docker build ci jobs * updated checkout ci action to v3 - node12 warning * incorperated arm64 build --------- Co-authored-by: Almar Klein <almar@almarklein.org>
- Loading branch information
1 parent
99ef739
commit 69aedda
Showing
3 changed files
with
80 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Dockerfile to build an image from the repo. | ||
# Note that the build context must be the root of the repo. | ||
# Used by CI to build the image that is pushed to ghcr. | ||
# Unpriviliged version that installs and runs as UID 1000. | ||
|
||
FROM python:3.10-slim-buster | ||
|
||
# Create unpriviliged user and group, including directory structure | ||
RUN groupadd -g 1000 timetagger && \ | ||
useradd -r -u 1000 -m -g timetagger timetagger && \ | ||
mkdir /opt/timetagger && \ | ||
chown timetagger:timetagger /opt/timetagger | ||
|
||
# Switch to unpriviliged user | ||
USER 1000 | ||
|
||
WORKDIR /opt/timetagger | ||
COPY . /opt/timetagger | ||
|
||
# Install dependencies (including optional ones that make uvicorn faster) | ||
# Upgrade pip to the lastest version | ||
RUN pip --no-cache-dir install pip --upgrade && \ | ||
# Install optional depedencies that make uvicorn faster | ||
pip --no-cache-dir install uvicorn uvloop httptools && \ | ||
# Install timetagger depedencies defined via setup.py | ||
pip install --no-cache-dir --no-warn-script-location -e . | ||
|
||
CMD ["python", "-m", "timetagger"] |