-
Notifications
You must be signed in to change notification settings - Fork 114
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
Move root-required bits of drama-free-django build into Dockerfile #5145
Changes from 3 commits
fb34088
f2269c6
8478002
270e1a6
a9a63bb
a6e09f5
7431fba
490fe09
3cd92f0
139f8d8
e936ae7
4433633
44fef31
5b963b4
8bf713f
72e7382
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 | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,23 @@ | ||||||
FROM centos:7 | ||||||
|
||||||
ENV SCL_PYTHON_VERSION python27 | ||||||
|
||||||
ENV DFD_DIR /src/cfgov-refresh | ||||||
|
||||||
# Must be world writable since alternate uid:gid may be patched in at `docker run` time. | ||||||
RUN mkdir -p ${DFD_DIR} && chmod 777 ${DFD_DIR} | ||||||
WORKDIR ${DFD_DIR} | ||||||
|
||||||
# Install dependencies | ||||||
RUN yum install -y centos-release-scl && \ | ||||||
curl -sL https://rpm.nodesource.com/setup_10.x | bash - && \ | ||||||
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \ | ||||||
yum install -y ${SCL_PYTHON_VERSION} gcc git nodejs which yarn && \ | ||||||
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. Is the inclusion of 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. Yes, I can remove that. I find it strange that CentOS doesn't have |
||||||
echo "source scl_source enable ${SCL_PYTHON_VERSION}" > /etc/profile.d/scl_python.sh && \ | ||||||
source /etc/profile && \ | ||||||
pip install -U pip && \ | ||||||
pip install -U git+https://github.com/cfpb/drama-free-django.git | ||||||
|
||||||
COPY _build.sh _test.sh docker-entrypoint.sh ./ | ||||||
|
||||||
ENTRYPOINT [ "./docker-entrypoint.sh"] | ||||||
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.
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,19 +22,6 @@ if [ ! -d "$cfgov_refresh_volume" ]; then | |
exit 1 | ||
fi | ||
|
||
# Install build requirements. | ||
yum install -y centos-release-scl | ||
yum install -y gcc git python27 | ||
|
||
source /opt/rh/python27/enable | ||
|
||
pip install -U pip | ||
pip install -U git+https://github.com/cfpb/drama-free-django.git | ||
|
||
curl -sL https://rpm.nodesource.com/setup_10.x | bash - | ||
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo | ||
yum install -y nodejs yarn | ||
|
||
# Run the frontend build. | ||
pushd "$cfgov_refresh_volume" | ||
./frontend.sh production | ||
|
@@ -62,13 +49,14 @@ no-drama build "${build_args[@]}" | |
echo "{}" > ./dfd_env.json | ||
|
||
# This is used by DFD to set Django's settings.STATIC_ROOT. | ||
echo '{"static_out": "../../../static"}' > ./dfd_paths.json | ||
# Q: Why do we need to override the default? | ||
# echo '{"static_out": "../static"}' > ./dfd_paths.json | ||
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. This is needed because the default drama-free-django behavior is to set its We instead want these files to go to @rosskarchner's open PR #5133 currently includes a change that would set the default static root to 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. Makes sense. I'll change it back. |
||
|
||
no-drama release \ | ||
"./$build_artifact" \ | ||
./dfd_env.json \ | ||
"$artifact_release" \ | ||
--paths ./dfd_paths.json | ||
"$artifact_release" #\ | ||
#--paths ./dfd_paths.json | ||
|
||
# Copy release artifact to source directory. | ||
cp "$release_artifact" "$cfgov_refresh_volume" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ set -x | |
|
||
artifact_filename=cfgov_current_build.zip | ||
artifact_volume=/cfgov | ||
dfd_test_dir=/tmp/dfd-test/release | ||
|
||
# Verify that the artifact volume has been mapped. | ||
if [ ! -d "$artifact_volume" ]; then | ||
|
@@ -16,15 +17,11 @@ if [ ! -d "$artifact_volume" ]; then | |
exit 1 | ||
fi | ||
|
||
# Install runtime requirements. | ||
yum install -y centos-release-scl | ||
yum install -y python27 | ||
|
||
source /opt/rh/python27/enable | ||
|
||
# Extract the artifact in /tmp. | ||
cp "$artifact_volume/$artifact_filename" /tmp | ||
cd /tmp | ||
mkdir -p $dfd_test_dir | ||
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. Not a big deal, but I'm curious why you made a new directory for this. I figured that working in /tmp was fine since the container is ephemeral. 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. The issue was that by having it in |
||
cp "$artifact_volume/$artifact_filename" $dfd_test_dir | ||
cd $dfd_test_dir | ||
python "./$artifact_filename" | ||
|
||
cd current | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
docker run -v `pwd`:/cfgov centos:6 /cfgov/docker/drama-free-django/_build.sh | ||
set -e | ||
|
||
docker build -t cfgov-dfd-builder docker/drama-free-django | ||
|
||
docker run \ | ||
--rm \ | ||
-u $(id -u):$(id -g) \ | ||
-v $(pwd):/cfgov \ | ||
cfgov-dfd-builder ./_build.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash --login | ||
# This entrypoint is used primarily as means of setting up a consistent | ||
# shell environment no matter which user the process runs as. By using | ||
# --login, it guarantees /etc/profile is always sourced, unlike the | ||
# non-login, non-interactive shell you get by default with `docker run`. | ||
|
||
exec "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
docker run -v `pwd`:/cfgov centos:6 /cfgov/docker/drama-free-django/_test.sh | ||
set -e | ||
|
||
docker build -t cfgov-dfd-builder docker/drama-free-django | ||
|
||
docker run \ | ||
--rm \ | ||
-u $(id -u):$(id -g) \ | ||
-v $(pwd):/cfgov:cached \ | ||
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. Why is 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. Unfortunately, it fails currently on Linux. I'll remove it. |
||
cfgov-dfd-builder ./_test.sh | ||
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. This shouldn't hold up this PR, but, if we are going to maintain this DFD testing capability, I wonder if it's worth entertaining the idea of a distinct Dockerfile just for that purpose. We don't really need everything in the "cfgov-dfd-builder" image just to run the DFD image, and it would be nice to actually determine what is needed. But probably thinking more about that should wait until/if we want to think about migrating Ansible code here. 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. Yeah, it does feel a little awkward to have the two scripts that both build the same image, but my assumption was that generally when you'd run As for a separate image, yeah we could. It just seemed like it'd be better to only maintain one Dockerfile that could do both. But if there's a scenario where we'd be running just |
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.
The current versions of the build and test scripts use
centos:6
(also documented here). I did this deliberately to try to match the current setup. Is there a particular reason to change that version here?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.
That was not intentional. Will fix.