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 DOCKER_TARGET a buid time argument only. #23076

Merged
merged 1 commit into from
Feb 14, 2025
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
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ RUN \
${HOME}/scripts/install_deps.py pip
EOF

# TODO: we should remove dependency on the environment variable
# and instead read from the /build-info file
ARG DOCKER_TARGET
ENV DOCKER_TARGET=${DOCKER_TARGET}

# Add our custom mime types (required for for ts/json/md files)
COPY docker/etc/mime.types /etc/mime.types
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/development/troubleshooting_and_debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Effective troubleshooting and debugging practices are essential for maintaining
## DEV_MODE vs DEBUG

In our project, `DEV_MODE` and `DEBUG` serve distinct but complementary purposes.
`DEV_MODE` is directly tied to the `DOCKER_TARGET` environment variable and is used to enable or disable behaviors
`DEV_MODE` is directly tied to the `DOCKER_TARGET` build argument and is used to enable or disable behaviors
based on whether we are running a production image or not.

For instance, production images always disables certain features like using fake fxa authentication. Additionally,
Expand Down
2 changes: 0 additions & 2 deletions scripts/install_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def main(targets):
# Constants
ALLOWED_NPM_TARGETS = set(['prod', 'dev'])
DOCKER_TAG = os.environ.get('DOCKER_TAG', 'local')
DOCKER_TARGET = os.environ.get('DOCKER_TARGET', '')
OLYMPIA_DEPS = os.environ.get('OLYMPIA_DEPS', '')
DEPS_DIR = os.environ.get('DEPS_DIR')
NPM_DEPS_DIR = os.environ.get('NPM_DEPS_DIR')
Expand All @@ -32,7 +31,6 @@ def main(targets):
'Updating deps... \n',
f'targets: {", ".join(targets)} \n',
f'DOCKER_TAG: {DOCKER_TAG} \n',
f'DOCKER_TARGET: {DOCKER_TARGET} \n',
f'OLYMPIA_DEPS: {OLYMPIA_DEPS} \n',
f'DEPS_DIR: {DEPS_DIR} \n',
f'NPM_DEPS_DIR: {NPM_DEPS_DIR} \n',
Expand Down
7 changes: 2 additions & 5 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
from olympia.lib.settings_base import * # noqa


# "production" is a named docker stage corresponding to the production image.
# when we build the production image, the stage to use is determined
# via the "DOCKER_TARGET" variable which is also passed into the image.
# So if the value is anything other than "production" we are in development mode.
DEV_MODE = DOCKER_TARGET != 'production'
# Any target other than "production" is considered a development target.
DEV_MODE = TARGET != 'production'

HOST_UID = os.environ.get('HOST_UID')

Expand Down
7 changes: 3 additions & 4 deletions src/olympia/lib/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import olympia.core.logger
import olympia.core.sentry
from olympia.core.utils import get_version_json


env = environ.Env()
Expand Down Expand Up @@ -64,10 +65,8 @@ def path(*folders):

DEBUG = env('DEBUG', default=False)

# Do NOT provide a default value, this should be explicitly
# set during the docker image build. If it is not set,
# we want to raise an error.
DOCKER_TARGET = env('DOCKER_TARGET')
# Target is the target the current container image was built for.
TARGET = get_version_json().get('target')

DEV_MODE = False

Expand Down
16 changes: 2 additions & 14 deletions tests/make/test_install_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ def _test_remove_existing_deps(self, args, expect_remove=False):

def test_keep_deps_for_local_mixed_env(self):
"""Test that dependencies are kept when running
locally with development deps in production"""
locally with development deps"""
args = {
'DOCKER_TAG': 'local',
'OLYMPIA_DEPS': 'development',
'DOCKER_TARGET': 'production',
}
self._test_remove_existing_deps(args, expect_remove=False)

Expand All @@ -75,21 +74,10 @@ def test_remove_deps_for_non_local(self):

def test_remove_deps_for_prod_deps_in_dev(self):
"""Test that dependencies are removed when
installing production deps in development"""
installing production deps"""
args = {
'DOCKER_TAG': 'local',
'OLYMPIA_DEPS': 'production',
'DOCKER_TARGET': 'development',
}
self._test_remove_existing_deps(args, expect_remove=True)

def test_remove_deps_for_prod_deps_in_prod(self):
"""Test that dependencies are removed when
installing production deps in production"""
args = {
'DOCKER_TAG': 'local',
'OLYMPIA_DEPS': 'production',
'DOCKER_TARGET': 'production',
}
self._test_remove_existing_deps(args, expect_remove=True)

Expand Down
Loading