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

Improve image security #562

Merged
merged 4 commits into from
Mar 14, 2024
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
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
venv/
documentation/
rego_clone/
.github/
docker/
Makefile
Dockerfile
.dockerignore
.gitignore
.pre-commit-config.yaml
12 changes: 7 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# BUILD STAGE ---------------------------------------
# split this stage to save time and reduce image size
# ---------------------------------------------------
FROM python:3.10-bullseye as BuildStage
FROM python:3.10-bookworm as BuildStage
# from now on, work in the /app directory
WORKDIR /app/
# Layer dependency install (for caching)
Expand All @@ -24,7 +24,7 @@ RUN cd /tmp/cedar-agent && \

# COMMON IMAGE --------------------------------------
# ---------------------------------------------------
FROM python:3.10-slim-bullseye as common
FROM python:3.10-slim-bookworm as common

# copy libraries from build stage (This won't copy redundant libraries we used in BuildStage)
COPY --from=BuildStage /usr/local /usr/local
Expand All @@ -39,7 +39,7 @@ RUN chmod +x ./wait-for.sh
RUN ln -s /opal/wait-for.sh /usr/wait-for.sh

# netcat (nc) is used by the wait-for.sh script
RUN apt-get update && apt-get install -y netcat jq && apt-get clean
RUN apt-get update && apt-get install -y netcat-traditional jq && apt-get clean

# copy startup script (create link at old path to maintain backward compatibility)
COPY ./scripts/start.sh .
Expand All @@ -48,7 +48,9 @@ RUN ln -s /opal/start.sh /start.sh
# copy gunicorn_config
COPY ./scripts/gunicorn_conf.py .
# copy app code
COPY . ./

COPY ./README.md .
COPY ./packages ./packages/
# install the opal-common package
RUN cd ./packages/opal-common && python setup.py install
# Make sure scripts in .local are usable:
Expand Down Expand Up @@ -142,7 +144,7 @@ USER opal
# ---------------------------------------------------
FROM common as server

RUN apt-get update && apt-get install -y openssh-client git curl && apt-get clean
RUN apt-get update && apt-get install -y openssh-client git && apt-get clean

USER opal

Expand Down
Loading