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
Update docker-compose examples #6566
Conversation
Changed volume bind mount from `./:/srv/app` to `./app:/srv/app` to match path used in PostgreSQL and MongoDB example Signed-off-by: azrikahar <42867097+azrikahar@users.noreply.github.com>
Signed-off-by: azrikahar <42867097+azrikahar@users.noreply.github.com>
Signed-off-by: azrikahar <42867097+azrikahar@users.noreply.github.com>
Signed-off-by: azrikahar <42867097+azrikahar@users.noreply.github.com>
Signed-off-by: azrikahar <42867097+azrikahar@users.noreply.github.com>
Signed-off-by: azrikahar <42867097+azrikahar@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## master #6566 +/- ##
=======================================
Coverage 19.85% 19.85%
=======================================
Files 857 857
Lines 12076 12076
Branches 1963 1963
=======================================
Hits 2398 2398
Misses 8093 8093
Partials 1585 1585
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
@alexandrebodin is the update correct? Because the update in on the code. |
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.
a minor change :)
docs/v3.x/installation/docker.md
Outdated
- ./data/db:/data/db | ||
ports: | ||
- '27017:27017' | ||
- ./db:/data/db |
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.
I would use ./data
so it is consistent between every examples :)
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.
Sorry for the late reply. Thank you for taking your time to change it. 👍
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.
LGTM ! Thanks for your contribution :)
* Change volume for strapi in SQLite for consistency Changed volume bind mount from `./:/srv/app` to `./app:/srv/app` to match path used in PostgreSQL and MongoDB example Signed-off-by: azrikahar <42867097+azrikahar@users.noreply.github.com> * Remove "links" option for PostgreSQL & MongoDB Signed-off-by: azrikahar <42867097+azrikahar@users.noreply.github.com> * Add "depends_on" option for PostgreSQL & MongoDB Signed-off-by: azrikahar <42867097+azrikahar@users.noreply.github.com> * Changed volume for strapi in MongoDB example Signed-off-by: azrikahar <42867097+azrikahar@users.noreply.github.com> * Add database init name environment variables Signed-off-by: azrikahar <42867097+azrikahar@users.noreply.github.com> * Remove exposed ports for databases Signed-off-by: azrikahar <42867097+azrikahar@users.noreply.github.com> * Update docker.md Co-authored-by: Alexandre BODIN <alexandrebodin@users.noreply.github.com> Signed-off-by: Gil Fernandes <gil.fernandes@onepointltd.com>
This PR only affects the documentation and is ready to be merged.
Description of what this PR changed:
Changed volume for strapi in SQLite from
./:/srv/app
to./app:/srv/app
Both the PostgreSQL and MongoDB strapi service binds to
./app
instead of./
, so this feels more uniform. It's also better to keep strapi into the./app
folder and not mixed up with the docker-compose file here.Removed
links
option for strapi service in PostgreSQL and MongoDBSince docker-compose v3, the
links
option became a legacy feature and may eventually be removed, as mentioned in the official Docker docs over here. Since docker-compose joins services/containers into the same network, they can already communicate to each other, as quoted from the previous docker docs link:In addition, the docker compose examples for postgresql and mongodb in the strapi-docker repo also seems to be more up-to-date in terms of docker compose v3 format, so I do believe having more updated format over here will be more consistent overall.
Add
depends_on
option for strapi service in PostgreSQL and MongoDBThis option is also used in the postgresql & mongodb docker compose example in strapi-docker. Since Strapi also often mentions the database needs to be up beforehand, this option added does seem more fitting. Just in case the reviewer is not sure what
depends_on
does, basically docker-compose will recognize that "strapi" service depends on the "postgres" or "mongo" service, so it will wait until the database service start first before starting strapi (there are some caveats, but it's explained in the official docs). More info on this option in the official Docker docs hereChanged volume for strapi in MongoDB from
./data/db:/data/db
to./db:/data/db
Since based on other tabs, strapi resides on
./app
of the base directory, postgres on./data
, I think it's also more uniform to have mongo to reside on./db
rather than nested in./data/db
. Once again this./db
approach is also used in the mongodb compose example in strapi-docker so it'll be more consistent as well.The following changes are more for clarity in my personal opinion, so if you guys deem them not necessary, I can revert these changes if you guys want me to.
Add
POSTGRES_DB
andMONGO_INITDB_DATABASE
environment variablesThese are also used in the strapi-docker examples to show a database is initialized with the name "strapi", as seen here (postgres) and here (mongodb). This is just to match how for postgres,
DATABASE_USERNAME
corresponds toPOSTGRES_USER
andDATABASE_PASSWORD
toPOSTGRES_PASSWORD
. Even though for the Postgres docker image it will automatically setPOSTGRES_DB
to the value ofPOSTGRES_USER
if it's not set, but I feel like setting it here will be clearer rather than hoping the user know the postgres image does this under the hood.Remove exposed ports for databases
Since the strapi service can already reach the database service, be it postgresql or mongodb, via the docker network, there is no need to expose the database port to the host machine. This is of course unless they have a database management application in their machine and wants to use
localhost:5432
orlocalhost:27017
to access the database. However for security purpose and in case someone does use this compose file in production, I believe it's best to not expose it until they opt-in to do so. The postgres example in strapi-docker also doesn't expose the port, though the mongodb one does. I do plan to create a pull request at strapi-docker if all these are approved over here.I have tested the updated compose file & there are no issues. If you guys wish to have the docker-compose logs for verification, do let me know so I can provide it, probably via pastebin since it's pretty lengthy. I do understand reviewing pull requests can be a long process, so I hope I gave sufficient details on what I changed and the reasoning behind the changes. Do let me know as well if you need any clarifications. Cheers