Skip to content

Commit

Permalink
chore: initialize mysql database in docker
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jniles committed May 12, 2024
1 parent c3ce8bd commit c0f24f2
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 39 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ USER node

ENV NODE_ENV production

LABEL org.opencontainers.image.source=https://github.com/third-Culture-Software/bhima
LABEL org.opencontainers.image.description="A hospital information management application for rural Congolese hospitals"
LABEL org.opencontainers.image.licenses=GPL

# Define startup command
CMD ["node", "server/app.js"]

9 changes: 5 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ services:
- backend

mysql:
image: mysql:8
image: mysql:8.3 # pin 8.3 ; https://github.com/appsignal/appsignal-nodejs/commit/0586d603c75aa12f8e99f4a5716fd8445f10d79c
restart: unless-stopped
command:
- --mysql-native-password=ON
#- --mysql-native-password=ON # See https://github.com/appsignal/appsignal-nodejs/commit/0586d603c75aa12f8e99f4a5716fd8445f10d79c
- --sql-mode=STRICT_ALL_TABLES,NO_UNSIGNED_SUBTRACTION
- --default-authentication-plugin=mysql_native_password
volumes:
- mysqldata:/var/lib/mysql/
- "./temp/docker-build.sql:/docker-entrypoint-initdb.d/bhima.sql"
- ./server/models:/docker-entrypoint-initdb.d
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=1
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_USER=$DB_USER
- MYSQL_PASSWORD=$DB_PASS
- MYSQL_DATABASE=$DB_NAME
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"build:db": "cross-env ./sh/build-database.sh",
"build:clean": "cross-env ./sh/build-init-database.sh",
"build:stock": "cross-env ./sh/build-stock-database.sh",
"build:docker": "cross-env ./sh/docker-init.sh",
"build:docker": "docker compose build",
"migrate": "cross-env ./sh/setup-migration-script.sh",
"watch": "cross-env ./node_modules/.bin/gulp watch",
"check:lang": "cross-env node ./utilities/translation/tfcomp.js client/src/i18n/en client/src/i18n/fr",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 0 additions & 34 deletions sh/docker-init.sh

This file was deleted.

0 comments on commit c0f24f2

Please sign in to comment.