fortrabbit / craft-copy

Deployment tools for Craft on fortrabbit
https://www.fortrabbit.com
MIT License
73 stars 8 forks source link

use git system config and build docker image locally #139

Closed erinbit closed 2 years ago

erinbit commented 2 years ago

Git system config

The previous bugfix (https://github.com/fortrabbit/craft-copy/pull/138) did not work because after adding the setting we override the global git config with the users git config. So here I set it in the system config instead, to avoid that conflict.

Local docker build

Repeatedly testing this by rebuilding container images and trying to keep the version of the craft-copy extension and the craft-copy docker image in sync I realised: why make it so difficult? Why try to sync two sources of truth? So in this pull request I added a simple local build of the docker image, no need to rely on the Github actions to build images anymore.

For example, this makes it possible to test this feature branch easily, by only running these commands:

composer require fortrabbit/craft-copy:dev-feature/git-system-config
nitro craft copy/nitro/setup
./nitro-craft copy/code/up

No need to wait for github actions to finish. No need to set a custom image tag to use for debugging. This will automatically build the correct image version locally.

Entrypoint vs command

I've also moved the "./craft" part from the ENTRYPOINT to the nitro-craft wrapper script. This is to make it easier to start the image with a shell for debugging, while still letting the entrypoint script fix file ownerships.

Before I had to specify to run entrypoint script to open a shell, took me a long time to figure out: docker run -it --rm -v "$PWD":/app --entrypoint=/entrypoint.sh ghcr.io/fortrabbit/craft-copy:8.0 sh

Now this happens automatically: docker run -it --rm -v "$PWD":/app ghcr.io/fortrabbit/craft-copy:8.0 sh

And still the wrapper script works as before: ./nitro-craft

What changed is that you used to be able to do this: docker run -it --rm -v "$PWD":/app ghcr.io/fortrabbit/craft-copy:8.0 copy/code/up Now you have to do this: docker run -it --rm -v "$PWD":/app ghcr.io/fortrabbit/craft-copy:8.0 ./craft copy/code/up But no one uses it like that I think :)