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

Make lockfiles optional for dev containers. #620

Merged
merged 1 commit into from
Feb 2, 2021
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
5 changes: 5 additions & 0 deletions .compose.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
COMPOSE_PROFILE=standalone

# Add extra paths to run project dependencies from local filesystem in editable mode
# The order of repositories in the list is important, it is `:` separated.
# DEV_SOURCE_PATH='pulpcore:pulp_ansible:galaxy_ng'
DEV_SOURCE_PATH='galaxy_ng'

# set to `0` to bypass requirements and install only from setup.py for each DEV_SOURCE_PATH
LOCK_REQUIREMENTS=1

# If you want to run the UI, clone https://github.com/ansible/ansible-hub-ui
# and set this to the path for the UI
# ANSIBLE_HUB_UI_PATH='/absolute/path/to/ansible-hub-ui'
1 change: 1 addition & 0 deletions CHANGES/257.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a new dev environment variable to bypass the installation of requirement lock files.
1 change: 1 addition & 0 deletions compose
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ fi
declare -xr DEV_SOURCE_PATH=${DEV_SOURCE_PATH:-galaxy_ng}
declare -xr COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-galaxy_ng}"
declare -xr COMPOSE_CONTEXT=".."
declare -xr LOCK_REQUIREMENTS="${LOCK_REQUIREMENTS:-1}"

exec docker-compose "${compose_args[@]}" "$@"
7 changes: 5 additions & 2 deletions dev/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ ARG USER_ID=1000
ARG USER_NAME=galaxy
ARG USER_GROUP=galaxy
ARG COMPOSE_PROFILE
ARG LOCK_REQUIREMENTS

ENV LANG=en_US.UTF-8 \
PYTHONUNBUFFERED=1 \
PULP_SETTINGS=/etc/pulp/settings.py \
DJANGO_SETTINGS_MODULE=pulpcore.app.settings
DJANGO_SETTINGS_MODULE=pulpcore.app.settings \
LOCK_REQUIREMENTS="${LOCK_REQUIREMENTS}"

RUN set -ex; \
id --group "${USER_GROUP}" &>/dev/null \
Expand Down Expand Up @@ -42,7 +44,8 @@ COPY ./requirements/requirements.common.txt /tmp/requirements.txt

RUN set -ex; \
pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir --requirement /tmp/requirements.txt
&& if [[ "${LOCK_REQUIREMENTS}" -eq "1" ]]; then \
pip install --no-cache-dir --requirement /tmp/requirements.txt; fi

# Install application
COPY . /app
Expand Down
8 changes: 8 additions & 0 deletions dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
build:
context: "${COMPOSE_CONTEXT}"
dockerfile: "dev/Dockerfile.base"
args:
LOCK_REQUIREMENTS: "${LOCK_REQUIREMENTS}"
image: "localhost/galaxy_ng/galaxy_ng:base"
entrypoint: "/bin/true"
tmpfs:
Expand All @@ -17,12 +19,15 @@ services:
build:
context: "${COMPOSE_CONTEXT}"
dockerfile: "dev/${COMPOSE_PROFILE}/Dockerfile"
args:
LOCK_REQUIREMENTS: "${LOCK_REQUIREMENTS}"
image: "localhost/galaxy_ng/galaxy_ng:${COMPOSE_PROFILE}"
command: ['run', 'api-reload']
ports:
- "5001:8000"
environment:
- "WITH_DEV_INSTALL=1"
- "LOCK_REQUIREMENTS=${LOCK_REQUIREMENTS}"
- "DEV_SOURCE_PATH=${DEV_SOURCE_PATH}"
env_file:
- './common/galaxy_ng.env'
Expand All @@ -42,6 +47,7 @@ services:
command: ['run', 'resource-manager']
environment:
- "WITH_DEV_INSTALL=1"
- "LOCK_REQUIREMENTS=${LOCK_REQUIREMENTS}"
- "DEV_SOURCE_PATH=${DEV_SOURCE_PATH}"
env_file:
- './common/galaxy_ng.env'
Expand All @@ -61,6 +67,7 @@ services:
command: ['run', 'worker']
environment:
- "WITH_DEV_INSTALL=1"
- "LOCK_REQUIREMENTS=${LOCK_REQUIREMENTS}"
- "DEV_SOURCE_PATH=${DEV_SOURCE_PATH}"
env_file:
- './common/galaxy_ng.env'
Expand All @@ -82,6 +89,7 @@ services:
- "24816:24816"
environment:
- "WITH_DEV_INSTALL=1"
- "LOCK_REQUIREMENTS=${LOCK_REQUIREMENTS}"
- "DEV_SOURCE_PATH=${DEV_SOURCE_PATH}"
env_file:
- './common/galaxy_ng.env'
Expand Down
4 changes: 3 additions & 1 deletion dev/standalone/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ FROM localhost/galaxy_ng/galaxy_ng:base
COPY requirements/requirements.standalone.txt /tmp/requirements.standalone.txt

RUN set -ex; \
pip install --no-cache-dir --requirement /tmp/requirements.standalone.txt
if [[ "${LOCK_REQUIREMENTS}" -eq "1" ]]; then \
pip install --no-cache-dir --requirement /tmp/requirements.standalone.txt; \
fi
9 changes: 8 additions & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set -o pipefail
readonly WITH_MIGRATIONS="${WITH_MIGRATIONS:-0}"
readonly WITH_DEV_INSTALL="${WITH_DEV_INSTALL:-0}"
readonly DEV_SOURCE_PATH="${DEV_SOURCE_PATH:-}"
readonly LOCK_REQUIREMENTS="${LOCK_REQUIREMENTS:-1}"


log_message() {
Expand All @@ -23,7 +24,13 @@ install_local_deps() {
src_path="/src/${item}"
if [[ -d "$src_path" ]]; then
log_message "Installing path ${item} in editable mode."
pip install --no-cache-dir --no-deps --editable "$src_path" >/dev/null

if [[ "${LOCK_REQUIREMENTS}" -eq "1" ]]; then
pip install --no-cache-dir --no-deps --editable "$src_path" >/dev/null
else
pip install --no-cache-dir --editable "$src_path" >/dev/null
fi

else
log_message "WARNING: Source path ${item} is not a directory."
fi
Expand Down