Skip to content

Commit

Permalink
Add template for building Python 3 chutes.
Browse files Browse the repository at this point in the history
  • Loading branch information
lhartung committed Apr 30, 2019
1 parent 385dce7 commit 308be2c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM {image}

# Set up an unprivileged user so that we can drop out of root.
# Make /home/paradrop so that npm can drop some files in there.
# Make /home/paradrop so that tools can drop some files in there.
# Make /opt/paradrop/app for installing the app files.
RUN useradd --system --uid 999 paradrop && \
mkdir -p /home/paradrop && \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM {image}

# Set up an unprivileged user so that we can drop out of root.
# Make /home/paradrop so that tools can drop some files in there.
# Make /opt/paradrop/app for installing the app files.
RUN useradd --system --uid 999 paradrop && \
mkdir -p /home/paradrop && \
chown paradrop /home/paradrop && \
mkdir -p /opt/paradrop/app && \
chown paradrop /opt/paradrop/app && \
chmod a+s /opt/paradrop/app

WORKDIR /opt/paradrop/app

# Add cap_net_bind_service to node so that it can bind to ports 1-1024.
# Not all images support this.
RUN setcap 'cap_net_bind_service=+ep' /usr/local/bin/node || true

# Install some useful tools and libraries.
RUN apt-get update && \
apt-get install -y \
iptables

{has_packages:if:RUN apt-get install -y {packages}}

# Defang setuid/setgid binaries.
RUN find / -perm +6000 -type f -exec chmod a-s {{}} \; || true

# Copy paradrop.yaml and requirements.txt, the latter only if it exists. These
# layers will be cached as long as the requirements do not change.
COPY paradrop.yaml requirements.tx[t] /opt/paradrop/app/
RUN if [ -f requirements.txt ]; then pip install --requirement requirements.txt; fi

# Now copy the rest of the files.
COPY . /opt/paradrop/app/
RUN chown paradrop:paradrop -R /opt/paradrop/app

{drop_root:if:USER paradrop}

CMD {cmd}

0 comments on commit 308be2c

Please sign in to comment.