-
Notifications
You must be signed in to change notification settings - Fork 98
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
Feature: deploy BHIMA using docker and docker-compose #7586
Feature: deploy BHIMA using docker and docker-compose #7586
Conversation
Adds a workflow to build and publish to Github Container Registry.
The following docker fixes are in place: - transitions to using npm in docker. - removes extraneous comments and environmental variables in dockerfile. The following compose fixes are in place: - adds a networking layer - uses the correct mysql 8.4 auth plugin call - removes the extraneous UTF8 variables - removes the deprecated version tag
The mysql dockerfile has been pinned at 8.3 to avoid errors in the default authentication plugin. See mysqljs/mysql#2233 for more information. It might be prudent to switch to mysql2 instead of mysqljs for future release. I've renamed all the server model files to have a numeric prefix to allow execution in order. The 99-debug.sql file crashes, but it is not necessary for the functioning of the BHIMA server. You can now type `docker-compose up` and be taken to the BHIMA installation page on localhost. Environmental variables are set in the `.env` file as usual.
Renames the sql files everywhere they are referenced to their new alphanumeric names.
Fixes the typo sever to server.
Fixes an issue with the user/password not being synchronized between the bhima and mysql containers.
…cker chore: build with docker
Adds the workflow_dispatch trigger to manually trigger docker builds from the actions menu.
…cker chore: allow manual trigger of builds
Adds a workflow to build and publish to Github Container Registry.
The following docker fixes are in place: - transitions to using npm in docker. - removes extraneous comments and environmental variables in dockerfile. The following compose fixes are in place: - adds a networking layer - uses the correct mysql 8.4 auth plugin call - removes the extraneous UTF8 variables - removes the deprecated version tag
The mysql dockerfile has been pinned at 8.3 to avoid errors in the default authentication plugin. See mysqljs/mysql#2233 for more information. It might be prudent to switch to mysql2 instead of mysqljs for future release. I've renamed all the server model files to have a numeric prefix to allow execution in order. The 99-debug.sql file crashes, but it is not necessary for the functioning of the BHIMA server. You can now type `docker-compose up` and be taken to the BHIMA installation page on localhost. Environmental variables are set in the `.env` file as usual.
Renames the sql files everywhere they are referenced to their new alphanumeric names.
Fixes the typo sever to server.
Fixes an issue with the user/password not being synchronized between the bhima and mysql containers.
Adds the workflow_dispatch trigger to manually trigger docker builds from the actions menu.
Creates the .env specifically for docker that omits key variables needed to be defined at runtime by the user.
Adds the .env to the ignored files list.
Uses dockerhub to avoid the GCR's permissions issues. The docker-compose file should now be able to run BHIMA without any further configuration.
Properly configure docker environment.
Provides defaults for all environmental variables. Adds installation instructions for docker-compose.
Adds a reference to the docker installation instructions.
…er-compose-installation-instructions chore(docker): fewer env file configurations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code changes look fine and will not interfere with normal Bhima installs.
Thanks for adding the Docker documentation.
I tested the normal test procedure on my local system and it ran without any problems.
I did not try running with the Docker setup, but I had tried that before on another system.
Other than a minor update to the Docker documentation, I think this is ready to go.
### System Requirements | ||
|
||
Currently, BHIMA is compatible only with the x64 architecture. If you are using other architectures (such as ARM64 or x86), please refer to alternative installation instructions. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may seem obvious, but it is probably a good idea to mention that you need to install 'docker' on your system to do any of the following docker operations!
@@ -19,7 +19,7 @@ function evaluate(startDate, endDate, dateBhMoment) { | |||
expect(formated).to.deep.equal(expected); | |||
} | |||
|
|||
describe('test/sever-unit/bhMoment', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Good catch.
Changes made! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
This PR adds a working docker-compose script, as well as a working BHIMA Dockerfile. Currently, the BHIMA docker build is hosted at thirdculturesoftware/bhima since I don't have permissions for this github repository anymore.
Note: if this PR is not wanted, it can be closed. I plan to continue formalizing docker as the main deployment method on a fork of BHIMA.
Here are the major changes:
Rewrite the BHIMA Dockerfile
I rewrote the
Dockerfile
to use npm, and removed all mention of yarn. This is in line with #7194. It also simplified the Dockerfile in the process. There are still future improvements that could be made, such as using a multistage build and ensuring that all the chromium dependencies are truly still needed. The current container forbhima
is ~1GB in size.The dockerfile also uses it's own
.env.docker
to set variables for the docker container that the user does not need to change.Rework docker-compose.yml
I ran into several bugs trying to get the docker-compose script to work. For the time being, mysql is pinned to version 8.3 since versions 8.4 and higher are not supported by mysqljs. The team should consider migrating to mysql2 for the BHIMA driver.
It is rumored to be a drop in replacement.. Update: I have shown that we can dropmysql2
into BHIMA without significant change in Third-Culture-Software#5.Many of the variables now have sensible defaults so the user does not have to set them in a
.env
file. Obviously for real deployments, the database password should be generated, not reused from this script. In the future, I'll likely work on generating the MySQL password and theSESS_SECRET
during thedocker compose up
call.To build the system with docker, I added installation instructions with docker here. Closes #6252.
Rename SQL scripts to
${number}-${scriptname}
In order to build the initial database with docker compose, the files are copied into an initial mysql data directory, then executed in alphabetical order. For that reason, I renamed all SQL scripts needed for an initial database to start with a number that specifies their execution order. I went through and updated all references to these scripts and tested by running the repository test scripts. If I missed something, let me know!
Trying it out
If you want to test this out, it should be as easy as checking out this branch and running
docker compose up
. Note that it might take a while. When the application is all settled, navigate to the port on your local system and you should be greeted by the clean BHIMA install.