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

Docker for local dev #525

Open
wants to merge 8 commits into
base: next
Choose a base branch
from

Conversation

sadiqkhoja
Copy link
Contributor

@sadiqkhoja sadiqkhoja commented Oct 20, 2023

Changes

  • Added a new docker-compose file for development. It is supposed to be executed in conjunction with the main docker-compose.yml. This new file adds profiles attribute to control which services are needed for particular development workflow. Additionally, network_mode is set to host driver so that bidirectional communication is possible. Bottleneck for bridge mode is Enketo which for some reason does not honour /etc/hosts for localhost, I was able to make it work with code modification on the fly, which looked dirty to me. One caveat for host mode: this is not available for "Docker Desktop for Mac", works great with OrbStack
  • Added dev config templates for nginx, enketo and service(central) services. These dev templates have hardcoded localhost endpoints

Two objectives I've kept in my mind to achieve this 1) Not to touch main docker-compose.yml that might cause unintended consequences 2) Not to modify application source code

What has been done to verify that this works as intended?

Verified locally. It would be great if all can try this and see if this is helpful.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

Although I have modified three startup scripts, changes are contained in dev specific conditional block

Does this change require updates to documentation? If so, please file an issue here and include the link below.

None

Before submitting this PR, please make sure you have:

  • verified that any code or assets from external sources are properly credited in comments or that everything is internally sourced

@sadiqkhoja sadiqkhoja marked this pull request as draft October 20, 2023 19:55
@sadiqkhoja sadiqkhoja marked this pull request as ready for review October 20, 2023 20:05
@matthew-white matthew-white changed the base branch from master to next October 24, 2023 19:33
@spwoodcock
Copy link
Member

Is work still ongoing on this PR?

I have just set up my own dev environment to work on central-backend and central-frontend & documented the process.
As a result, I have a slightly modified dev setup, also with a docker-compose.dev.yml.

I plan to submit my documentation for review, but should I also commit the dev setup changes?

@sadiqkhoja
Copy link
Contributor Author

Hi @spwoodcock, I will be working again on this PR next week, particularly removing duplicate *.json.dev.template from the individual services.

Can you please share your setup, is it a different approach? Maybe we can combine both.

@spwoodcock
Copy link
Member

Certainly!

I made a PR in our repo to more easily show the changes: https://github.com/hotosm/odkcentral/pull/1/files

My main goal was to make setting up a dev environment as easy as possible, with files mounted in the container for hot reload (on the backend). I planned to do the same for the frontend, running the dev server with hot reloading, but we may need to update vue-cli-service and node forman to vite.

I extended from the existing docker-compose.yml, so had to make a mock enketo service so nginx would start up correctly (as I only wanted to develop for central-backend and central-frontend).

Hope this helps - I'm more than happy to contribute to this PR if needed.

It is supposed to be executed in conjuction with main file i.e. docker-compose.yml.
Added Makefile to run containers for enketo/central development
Fixes start-postgres.sh: unable to see .postgres14-upgrade-successful when data directory is not present
@sadiqkhoja sadiqkhoja force-pushed the docker-for-local-dev branch 3 times, most recently from 837fb5e to 73d14ba Compare February 12, 2024 23:21
…e provided;

this is required for running the setup on Apple chip.
Get ride of  it's not available on all docker compose versions
@@ -0,0 +1,17 @@
.PHONY: for-central-dev
for-central-dev:
docker compose --profile secrets -f docker-compose.yml -f docker-compose.dev.yml up
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Running secrets container first to generate hardcoded secrets for dev.

can't override depends_on in docker-compose.dev.yml because !override is not released in OrbStack

@@ -1,5 +1,5 @@
# see: https://github.com/tianon/docker-postgres-upgrade/blob/master/9.6-to-14/Dockerfile
FROM tianon/postgres-upgrade:9.6-to-14
FROM --platform=linux/amd64 tianon/postgres-upgrade:9.6-to-14
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this image is available for amd64 architecture, we need to specify this we running it on apple chip (M1/M2/arm64)

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.

2 participants