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 dockerfile commands with correct user. #12579

Merged
merged 27 commits into from
Oct 22, 2019
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6412631
tmp
EnTeQuAk Sep 26, 2019
ff10060
Run dockerfile commands with correct user.
EnTeQuAk Sep 26, 2019
747a477
Correct if statement
EnTeQuAk Oct 10, 2019
1bc7fc3
Use separate tag for easier testing
EnTeQuAk Oct 10, 2019
b9fb5b6
Merge branch 'master' of github.com:mozilla/addons-server into 12366-…
EnTeQuAk Oct 11, 2019
b60b532
Merge branch 'master' of github.com:mozilla/addons-server into 12366-…
EnTeQuAk Oct 14, 2019
4dd8fdb
Try running directly with user olympia
EnTeQuAk Oct 14, 2019
a405386
Merge branch '12366-fix-docker-builds' of github.com:mozilla/addons-s…
EnTeQuAk Oct 15, 2019
cd3fb54
Merge branch '12366-fix-docker-builds' of github.com:mozilla/addons-s…
EnTeQuAk Oct 15, 2019
1166098
Small cleanup
EnTeQuAk Oct 15, 2019
b32f01b
Merge branch '12366-fix-docker-builds' of github.com:mozilla/addons-s…
EnTeQuAk Oct 16, 2019
81e69d5
Add docs
EnTeQuAk Oct 16, 2019
a8644f3
Merge branch 'master' of github.com:mozilla/addons-server into 12366-…
EnTeQuAk Oct 16, 2019
23e8588
Fix comment
EnTeQuAk Oct 16, 2019
c327835
Merge branch 'master' of github.com:mozilla/addons-server into 12366-…
EnTeQuAk Oct 17, 2019
70c6954
Add 'rootshell' command
EnTeQuAk Oct 21, 2019
612846f
Build circleci for local dev
EnTeQuAk Oct 21, 2019
56c10f1
Fix pip execution by using 'python -m' to fetch the correct pip
EnTeQuAk Oct 21, 2019
ebde18b
Pick up upstream user/group for builds and implement PYTHONUSERBASE a…
EnTeQuAk Oct 21, 2019
5f42bf1
Correctly pass USER_ID and GROUP_ID to Dockerfile when building
EnTeQuAk Oct 21, 2019
24214fa
Small cleanups
EnTeQuAk Oct 21, 2019
7efd7b1
Build our test branch
EnTeQuAk Oct 21, 2019
2138430
Merge branch 'master' of github.com:mozilla/addons-server into 12366-…
EnTeQuAk Oct 21, 2019
f3efb69
Merge branch '12366-fix-docker-builds' of github.com:mozilla/addons-s…
EnTeQuAk Oct 21, 2019
aa22fb0
Fall back to manual uploads for testing
EnTeQuAk Oct 21, 2019
853a6da
Cleanup
EnTeQuAk Oct 22, 2019
ef54110
Revert back to :latest tag
EnTeQuAk Oct 22, 2019
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
Prev Previous commit
Next Next commit
Pick up upstream user/group for builds and implement PYTHONUSERBASE a…
…nd PIP_USER
  • Loading branch information
EnTeQuAk committed Oct 21, 2019
commit ebde18b67d3dc3f823057feccd6a02367dad91cc
31 changes: 24 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ FROM python:3.6-slim-stretch

ENV PYTHONDONTWRITEBYTECODE=1

ARG GROUP_ID=1000
ARG USER_ID=1000
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These require --build-arg GROUP_ID=$(id -g) --build-arg USER_ID=$(id -u) - I'll add docs about that later - I found that we don't have any docs at all about local building so I'll do that together with fixing circleci automatic builds (for local dev) as this may change requirements.


# Run all initial setup with root user. This is the default but mentioned here
# for documentation.
# We won't switch to the `olympia` user inside the dockerfile
Expand Down Expand Up @@ -77,21 +80,35 @@ ENV LC_ALL en_US.UTF-8
COPY . /code
WORKDIR /code

RUN groupadd -g ${GROUP_ID} olympia
RUN useradd -g ${GROUP_ID} -u ${USER_ID} -Md /deps/ olympia

# Create /deps/ and move ownership over to `olympia` user so that
# we can install things there
# Also run `chown` on `/code/` which technically doesn't change permissions
# on the host but ensures that the image knows about correct permissions.
RUN mkdir /deps/ && chown -R olympia:olympia /deps/ /code/

ENV PIP_BUILD=/deps/build/
ENV PIP_CACHE_DIR=/deps/cache/
ENV PIP_SRC=/deps/src/

# Allow us to install all dependencies to the `olympia` users
# home directory (which is `/deps/`)
ENV PIP_USER=true
env PYTHONUSERBASE=/deps

# Make sure that installed binaries are accessible
ENV PATH $PYTHONUSERBASE/bin:$PATH

ENV NPM_CONFIG_PREFIX=/deps/
ENV SWIG_FEATURES="-D__x86_64__"

RUN useradd -Md /code/ olympia
# From now on run everything with the `olympia` user by default.
USER olympia

# Install all python requires
RUN mkdir -p /deps/{build,cache,src}/ && \
ln -s /code/package.json /deps/package.json && \
RUN ln -s /code/package.json /deps/package.json && \
make update_deps && \
# Ensure that we are able to update dependencies ourselves later when
# using the `olympia` user by default.
chown -R olympia:olympia /deps/ && \
rm -rf /deps/build/ /deps/cache/

# Preserve bash history across image updates.
Expand Down