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

When create a new lucky app, the postgres_data volume never work as expected. #798

Closed
zw963 opened this issue Apr 22, 2023 · 2 comments · Fixed by #799
Closed

When create a new lucky app, the postgres_data volume never work as expected. #798

zw963 opened this issue Apr 22, 2023 · 2 comments · Fixed by #799

Comments

@zw963
Copy link
Contributor

zw963 commented Apr 22, 2023

When create a new lucky app, will create a docker-compose.yml like this

    volumes:
      - type: volume
        source: postgres_data
        target: /var/lib/postgresql

But above code never work, because postgres offical Dockerfile create a new volume early from /var/lib/postgresql/data, which cause latter bind mount from /var/lib/postgresql always a empty data folder, because data folder below /var/lib/postgresql is a mounted volume.

if check docker inspect, you can see two mount point.

        "Mounts": [
            {
                "Type": "volume",
                "Name": "clover_postgres_data",
                "Source": "/docker/containers/volumes/clover_postgres_data/_data",
                "Destination": "/var/lib/postgresql",
                "Driver": "local",
                "Mode": "z",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "volume",
                "Name": "1e7cb97e7e08dbd0f38dd4855e19e7e5497afc50dcf7bd4d1819b2e06716593d",
                "Source": "/docker/containers/volumes/1e7cb97e7e08dbd0f38dd4855e19e7e5497afc50dcf7bd4d1819b2e06716593d/_data",
                "Destination": "/var/lib/postgresql/data",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],

The fix is quite simple, just change target: /var/lib/postgresql into target: /var/lib/postgresql/data.

I give some advice in discuss here too, but, i guess someone miss this question. 😄

If consider accept contribute on those changes, i will create a PR for fix this.

@zw963
Copy link
Contributor Author

zw963 commented Apr 22, 2023

BTW: to verify the volume postgres_data never work, you can try:

  1. docker-compose up
  2. create a record.
  3. docker-compose down to remove postgres container.
  4. docker-compose up again.
  5. your's record disappear ...

because db data never save to a referenceable volume ... when you docker-compose up again, it created a new dangling value instead, that will create many disk space, and produce unused data.

@jwoertink
Copy link
Member

Sure, you can send a PR for that fix. I think that makes sense 👍

zw963 added a commit to zw963/lucky_cli that referenced this issue Apr 23, 2023
1. use short volume bind syntax.
2. fix postgres volume issue, check luckyframework#798.
3. Add POSTGRES_DB env for clarify.
4. Add crystal build cache into volume for better performance.
zw963 added a commit to zw963/lucky_cli that referenced this issue Apr 23, 2023
1. use short volume bind syntax.
2. fix postgres volume issue.
   check luckyframework#798.
3. Add POSTGRES_DB env for clarify,
   check luckyframework/lucky#1791 (reply in thread)
4. Add crystal build cache into volume for better performance.
zw963 added a commit to zw963/lucky_cli that referenced this issue Apr 23, 2023
1. use short volume bind syntax.
2. fix postgres volume issue.
   check luckyframework#798
3. Add POSTGRES_DB env for clarify.
   check luckyframework/lucky#1791
4. Add crystal build cache into volume for better performance.
jwoertink pushed a commit that referenced this issue May 14, 2023
* Refine docker-compose.yml:

1. use short volume bind syntax.
2. fix postgres volume issue.
   check #798
3. Add POSTGRES_DB env for clarify.
   check luckyframework/lucky#1791
4. Add crystal build cache into volume for better performance.

* Refine dev_entrypoint.sh

* Add shards cache as volume

* Add app/bin into volume for isolation the binaries created from container with locals.
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 a pull request may close this issue.

2 participants