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

Use docker compose for development #1894

Merged
merged 8 commits into from
Mar 27, 2024
Merged

Use docker compose for development #1894

merged 8 commits into from
Mar 27, 2024

Conversation

anthonyshull
Copy link
Contributor

@anthonyshull anthonyshull commented Feb 20, 2024

Pulling this branch will delete all of the contents of your .envrc file. That is because Docker can use a .env file to load environment variables. So, we use that instead. Before pulling this branch, copy your .envrc file to /tmp. Pull this branch and then copy /tmp/.envrc to ./.env. The only difference between the two is that .env removes the export from each line. Do that on the new file and it will work with Docker. .env is in .gitignore but .envrc no longer is so be very careful if you commit anything to this particular branch as I already accidentally committed sensitive information.

Check the README and make sure it accurately depicts how to use docker compose.

@anthonyshull anthonyshull reopened this Mar 25, 2024
@anthonyshull anthonyshull marked this pull request as ready for review March 25, 2024 13:26
@anthonyshull anthonyshull requested a review from a team as a code owner March 25, 2024 13:26
.envrc Show resolved Hide resolved
Copy link
Collaborator

@thecristen thecristen left a comment

Choose a reason for hiding this comment

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

I can't run the dev application locally because the redis-cluster-init service keeps exiting for me, but the rest seems to be working well! I'd like to get it fully working before I approve though, will figure it out offline.

I also don't think it's necessary to switch from .envrc to .env at all! I managed to get it working by listing the values under the environment key and just pulling the values from the system e.g.

environment:
  - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
  - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
  - DRUPAL_ROOT=${DRUPAL_ROOT-https://live-mbta.pantheonsite.io}
  - MIX_ENV=dev
  - OPEN_TRIP_PLANNER_URL=${OPEN_TRIP_PLANNER_URL-http://otp2-local.mbtace.com}
  - REDIS_PORT=${REDIS_PORT}
  - V3_API_KEY=${V3_API_KEY}
  - V3_API_VERSION=${V3_API_VERSION}
  - V3_URL=${V3_URL-https://api-dev.mbtace.com}

And I even (last night) managed to figure out how to get the changes from #1940 to be compatible - I added this call to my .envrc, and with a tweak to the ExAws config to look for the environment variables, it all just worked ✨

# exports AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY
$(aws configure export-credentials --profile default --format env)

@anthonyshull
Copy link
Contributor Author

Yeah, we could always have manually listed every environment variable in the docker file, but then we have to maintain both. The idea was to have a single file to maintain that works whether or not you're working with Docker. If we pursue your path, adding or removing an environment variable means maintaining it in two places. Changing to .env means only having to maintain one file and it literally takes 5 seconds to search and replace export with ``.

@anthonyshull
Copy link
Contributor Author

Also, btw, you can export the AWS credentials without the export with:

$(aws configure export-credentials --format env-no-export)

@thecristen
Copy link
Collaborator

Also, btw, you can export the AWS credentials without the export with:

$(aws configure export-credentials --format env-no-export)

@anthonyshull Where would you want devs to invoke this? It doesn't appear to work in .env files.

Unless more useful elsewhere, might make sense to add $(aws configure export-credentials --format env) to the .envrc though!

@thecristen thecristen added the dev-blue Deploy to dev-blue label Mar 26, 2024
Copy link
Collaborator

@thecristen thecristen left a comment

Choose a reason for hiding this comment

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

Thanks for giving me more time with this. I think it'll work out. 🥳

.env.template Outdated Show resolved Hide resolved
deploy/dev.yml Show resolved Hide resolved
.env.template Outdated Show resolved Hide resolved
deploy/dev.yml Show resolved Hide resolved
@anthonyshull anthonyshull merged commit 2ac068e into master Mar 27, 2024
18 of 19 checks passed
@anthonyshull anthonyshull deleted the ags/docker-compose branch March 27, 2024 13:51
@github-actions github-actions bot removed the dev-blue Deploy to dev-blue label Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants