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

Revamped docker compose #3324

Merged
merged 26 commits into from
Jan 17, 2024
Merged

Revamped docker compose #3324

merged 26 commits into from
Jan 17, 2024

Conversation

Anish9901
Copy link
Member

@Anish9901 Anish9901 commented Nov 24, 2023

Fixes #3306

For the reviewer:

  • Not adding any technical details here as the docker compose file should be self explanatory.
  • Please go through the docker-compose.yml file, read through the comments and try setting up the prod version of Mathesar.
  • Please report any feedback and/or difficulty you faced during the installation.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@Anish9901 Anish9901 marked this pull request as ready for review November 28, 2023 17:29
@Anish9901 Anish9901 added the pr-status: review A PR awaiting review label Nov 28, 2023
@Anish9901 Anish9901 added this to the v0.1.4 milestone Nov 28, 2023
Copy link
Contributor

@mathemancer mathemancer left a comment

Choose a reason for hiding this comment

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

Overall, this is really great. Nice work, @Anish9901 !

I made some changes to get the unified docker image to work. I'd like for you to look at those before we have others work through this.

x-config: &config
# (Required) Replace '?' with '-' followed by your 50 character long Django
# SECRET_KEY, you can generate one here: https://djecrety.ir/
SECRET_KEY: ${SECRET_KEY:?}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm debating whether we should include a default key that's obviously unfit for production. Something like:

Suggested change
SECRET_KEY: ${SECRET_KEY:?}
SECRET_KEY: ${SECRET_KEY:-PLEASEDONOTUSETHISSECRETKEYITISSUPERDUPERINSECURE}

Copy link
Contributor

Choose a reason for hiding this comment

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

After some discussion in various channels, I think the current failure state is better in this use-case.

@mathemancer
Copy link
Contributor

@kgodey For testing, you need to run

docker build -t mathesar/mathesar-prod:latest --build-arg PYTHON_REQUIREMENTS=requirements-prod.txt .
docker build -t mathesar/mathesar-caddy:latest -f Dockerfile.caddy .

from the root of the repo. This is because we haven't yet published the new images for 0.1.4. Actual users won't need to do that.

Then, just copy the docker compose file to any directory you want to use for the test installation, and follow the instructions in that file. I recommend using some directory other than the repo to avoid contamination from any dev files (e.g., .env) in the repo, and since this setup adds subdirectories under wherever it's run (as documented in the file).

export POSTGRES_PASSWORD=mathesar
export POSTGRES_HOST=localhost
export POSTGRES_PORT=5432
export POSTGRES_DB=mathesar_django
if [[ -z "${MATHESAR_DATABASES}" ]]; then
Copy link
Member Author

Choose a reason for hiding this comment

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

@mathemancer this script fails when all the POSTGRES_* variables are explicitly provided but MATHESAR_DATABASES isn't.

Here is the command I ran:

docker run \
-e POSTGRES_DB=mathesar_django \
-e POSTGRES_HOST=localhost \
-e POSTGRES_PORT=5432 \
-e POSTGRES_USER=mathesar \
-e POSTGRES_PASSWORD='mathesar' \
-v static:/code/static \
-v media:/code/media \
-v postgresql_config:/etc/postgresql/ \
-v postgresql_data:/var/lib/postgresql/ \
--name mathesar_service  \
-p 8000:8000 \
--restart unless-stopped \
mathesar/mathesar-prod:latest

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch; I've pushed a commit to fix it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Works perfectly after the fix, Brent!

@seancolsen seancolsen assigned kgodey and unassigned mathemancer Jan 10, 2024
@seancolsen
Copy link
Contributor

I've unassigned @mathemancer and assigned @kgodey per this comment from @mathemancer

@mathemancer
Copy link
Contributor

After chatting in other channels, I'm going to merge this, and we'll handle issues in future PRs.

@mathemancer mathemancer added this pull request to the merge queue Jan 17, 2024
Merged via the queue into develop with commit 1a14e80 Jan 17, 2024
17 checks passed
@mathemancer mathemancer deleted the docker-compose branch January 17, 2024 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: review A PR awaiting review
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Make the docker compose file self documenting
4 participants