Skip to content

Define the ENV setting for all environments (including test/build/local) #23073

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

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

KevinMind
Copy link
Contributor

@KevinMind KevinMind commented Feb 13, 2025

Fixes: mozilla/addons#15358

Description

Defines a gloabl ENV setting and documents its purpose and meaning.

Testing

You can inspect for build,test,local.

Build

Anywhere in the dockerfile add

RUN echo "env: ${ENV}"

Run the build

make docker_build_web DOCKER_PROGRESS=plain

Expect to see "env: build"

Test

In any test add

print('env', os.environ.get('ENV'))
print('env_setting', settings.ENV)

Expect both to print "test"

Local

run make down && make up (to ensure new compose settings are applied

Check in the terminal

make shell
printenv

Expect ENV=local in there

Check in settings

make djshell
settings.ENV

Expect "local" to be returned

Screenshots

image

Checklist

  • Add #ISSUENUM at the top of your PR to an existing open issue in the mozilla/addons repository.
  • Successfully verified the change locally.
  • The change is covered by automated tests, or otherwise indicated why doing so is unnecessary/impossible.
  • Add before and after screenshots (Only for changes that impact the UI).
  • Add or update relevant docs reflecting the changes made.

@KevinMind KevinMind requested review from a team and diox and removed request for a team February 13, 2025 11:11
@KevinMind KevinMind force-pushed the kevinmind/addons/153310-static-check branch 2 times, most recently from d28a310 to 4e4b6a1 Compare February 13, 2025 17:51
@KevinMind KevinMind force-pushed the kevinmind/addons/153310-static-check branch from 4e4b6a1 to d045ed4 Compare February 14, 2025 09:00
@KevinMind KevinMind force-pushed the kevinmind/addons/153310-static-check branch from d045ed4 to a3a85b0 Compare February 14, 2025 10:29
@KevinMind KevinMind requested review from eviljeff and removed request for diox February 14, 2025 16:48
Copy link
Member

@eviljeff eviljeff left a comment

Choose a reason for hiding this comment

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

I couldn't verify the build testing steps - I'd already done make up by the time I read the instructions so I guess everything was cached(?) because I didn't see any print output.

@KevinMind
Copy link
Contributor Author

I couldn't verify the build testing steps - I'd already done make up by the time I read the instructions so I guess everything was cached(?) because I didn't see any print output.

If you add a line in the docker file it will invalidate the cache. Should be pretty trivial to reproduce.

@eviljeff
Copy link
Member

I couldn't verify the build testing steps - I'd already done make up by the time I read the instructions so I guess everything was cached(?) because I didn't see any print output.

If you add a line in the docker file it will invalidate the cache. Should be pretty trivial to reproduce.

I added the RUN echo "env: ${ENV}" to the end and it didn't.

@KevinMind
Copy link
Contributor Author

I couldn't verify the build testing steps - I'd already done make up by the time I read the instructions so I guess everything was cached(?) because I didn't see any print output.

If you add a line in the docker file it will invalidate the cache. Should be pretty trivial to reproduce.

I added the RUN echo "env: ${ENV}" to the end and it didn't.

Did you run with DOCKER_TARGET=production? If not, then it would've just skipped that stage. You could add it to the base stage and it will always run.

@KevinMind
Copy link
Contributor Author

Confirming it does work

image

@KevinMind KevinMind merged commit 7d45186 into master Feb 19, 2025
41 checks passed
@KevinMind KevinMind deleted the kevinmind/addons/153310-static-check branch February 19, 2025 08:51
@eviljeff
Copy link
Member

I couldn't verify the build testing steps - I'd already done make up by the time I read the instructions so I guess everything was cached(?) because I didn't see any print output.

If you add a line in the docker file it will invalidate the cache. Should be pretty trivial to reproduce.

I added the RUN echo "env: ${ENV}" to the end and it didn't.

Did you run with DOCKER_TARGET=production? If not, then it would've just skipped that stage. You could add it to the base stage and it will always run.

I ran exactly what was specified in the testing steps above: make docker_build_web DOCKER_PROGRESS=plain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Define ENV for all possible environments.
2 participants