-
Notifications
You must be signed in to change notification settings - Fork 30
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
Don't run as root when building protobuf files #251
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,15 +6,23 @@ RUN set -ex && \ | |
apt-get install -y --no-install-recommends \ | ||
python3-pip | ||
|
||
# Install Python dev dependencies. | ||
COPY ./dev-requirements.txt /tmp/ | ||
RUN python3 -m pip install --upgrade pip && \ | ||
python3 -m pip install --requirement /tmp/dev-requirements.txt | ||
|
||
# Install Rust cargo. | ||
RUN set -ex && \ | ||
apt-get install -y --no-install-recommends \ | ||
curl \ | ||
build-essential | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y | ||
ENV PATH="/root/.cargo/bin:${PATH}" | ||
|
||
# Install Python dev dependencies. | ||
COPY ./dev-requirements.txt /tmp/ | ||
RUN python3 -m pip install --upgrade pip && \ | ||
python3 -m pip install --requirement /tmp/dev-requirements.txt | ||
# Switch user | ||
ARG uid=1000 | ||
RUN useradd -u ${uid} -s /bin/sh -m builder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got an error: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting, I'll try to take a look later this week. |
||
|
||
USER builder | ||
WORKDIR /home/builder | ||
|
||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y | ||
ENV PATH="/home/builder/.cargo/bin:${PATH}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
# 3.18.2 | ||
FROM alpine@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b | ||
RUN apk add --update protoc protobuf-dev go git | ||
|
||
# Switch user | ||
ARG uid=1000 | ||
RUN adduser -u ${uid} -S builder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alpine does not use the "standard" |
||
|
||
RUN mkdir -p /home/builder | ||
RUN chown builder /home/builder | ||
|
||
USER builder | ||
WORKDIR /home/builder | ||
|
||
RUN go install github.com/chrusty/protoc-gen-jsonschema/cmd/[email protected] | ||
|
||
# This is required to get the field_behavior.proto file | ||
# NOTE: --filter=tree:0 performs a treeless clone; we do this to optimize cloning | ||
# this otherwise relatively heavy repository. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing locally, I had to move lines 14-18, the apt-get for curl and build-essential, above 10-12, or else it failed with
E: Failed to fetch http://deb.debian.org/debian/pool/main/p/perl/perl-modules-5.32_5.32.1-4%2bdeb11u2_all.deb 404 Not Found [IP: 151.101.22.132 80]
(not sure why). Can we swap the order?