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

Run containers as non-root & reduce the size of pcw image #217

Merged
merged 2 commits into from
Feb 22, 2023
Merged
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
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COPY requirements.txt /pcw/
# * Install system requirements
# * Install pip requirements
# * Empty system cache to conserve some space
RUN zypper -n in python310-devel gcc libffi-devel aws-cli && pip3.10 install -r /pcw/requirements.txt && rm -rf /var/cache
RUN zypper -n in python310-devel gcc libffi-devel aws-cli && pip install --no-cache-dir -r /pcw/requirements.txt && rm -rf /var/cache
asmorodskyi marked this conversation as resolved.
Show resolved Hide resolved

# Copy program files only
COPY ocw /pcw/ocw/
Expand All @@ -28,5 +28,8 @@ VOLUME /pcw/db

EXPOSE 8000/tcp

RUN useradd --no-create-home --uid 1777 --user-group --shell /bin/false pcw && chown -R pcw:pcw /pcw
USER pcw

# Once we are certain that this runs nicely, replace this with ENTRYPOINT.
CMD ["/pcw/container-startup", "run"]
5 changes: 4 additions & 1 deletion Dockerfile_dev
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ COPY requirements.txt requirements_test.txt requirements_k8s.txt /tmp/
# * Install system requirements
# * Install pip requirements
# * Empty system cache to conserve some space
RUN zypper -n in python310-devel gcc libffi-devel aws-cli && pip3.10 install -r /tmp/requirements_test.txt && rm -rf /var/cache
RUN zypper -n in python310-devel gcc libffi-devel aws-cli && pip install --no-cache-dir -r /tmp/requirements_test.txt && rm -rf /var/cache

ricardobranco777 marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR /pcw

RUN useradd --no-create-home --uid 1000 --user-group --shell /bin/false pcw && chown -R pcw:pcw /pcw
USER pcw

ENTRYPOINT ["sh", "-c"]
4 changes: 4 additions & 0 deletions Dockerfile_k8s
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ COPY cleanup_k8s.py LICENSE README.md setup.cfg /pcw/
ENV PATH ${PATH}:/opt/google-cloud-sdk/bin/

WORKDIR /pcw

RUN useradd --no-create-home --uid 1777 --user-group --shell /bin/false pcw && chown -R pcw:pcw /pcw
USER pcw

CMD ["python3", "cleanup_k8s.py"]
3 changes: 3 additions & 0 deletions Dockerfile_k8s_dev
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ ENV PATH ${PATH}:/opt/google-cloud-sdk/bin/

WORKDIR /pcw

RUN useradd --no-create-home --uid 1000 --user-group --shell /bin/false pcw && chown -R pcw:pcw /pcw
USER pcw

ENTRYPOINT ["sh", "-c"]