Skip to content

Commit

Permalink
Merge pull request #34 from smartbooster/refacto_docker_generate_lock
Browse files Browse the repository at this point in the history
Refacto docker generate lock
  • Loading branch information
mathieu-ducrot committed Jan 5, 2024
2 parents d1411c1 + 4e6c69c commit b4b5ceb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ Depending on your current situation, choose among the following the right step t
### Setup the docker stack from an empty repository

```shell
# First clone your project if you haven't and cd into it
git clone git@gitlab.com:path/your/project-name.git
cd project-name
# Add the symfony-docker remote to fetch the stack files
git remote add docker git@github.com:smartbooster/symfony-docker.git
git fetch docker
git checkout docker/main .
mv .env.skeleton .env
# Generate the lock file and remove the remote
make docker-generate-lock
git remote remove docker
```

Expand Down Expand Up @@ -70,6 +74,7 @@ Be sure that the docker stack of the project is stop before doing the following
git remote add docker git@github.com:smartbooster/symfony-docker.git
git fetch docker
git checkout docker/main .
make docker-generate-lock
git remote remove docker
make docker-post-fetch
```
Expand All @@ -81,7 +86,10 @@ make docker-post-fetch
- MYSQL_ADDON_URI replace your current value with mysql://dev:dev@mysql:3306/{APPLICATION} (replace {APPLICATION} with the value of APPLICATION)
- Then do a `make up`, wait to see "MySQL init process done. Ready for start up.", and on another terminal do a `make install`.
- Check that the project still works the same as before fetching the docker stack.
- Make sure your `gitlab-ci.yaml` build-image and test jobs have the same content as written in this repository.
- Be sure to add the generated symfony-docker.lock to your committed files to keep track of which version of the stack is setup on your project.
- Check that the changes in the directories docker and make, as well as the docker-compose.yml and Dockerfile files, are consistent then commit them on your project repository.
- On Clever Cloud, go to each environment application and check the value of the `CC_POST_BUILD_HOOK` environment variable. According to your needs, update which files should be set.

All the steps above need to be done only once. Next you can refer to the next section to see how to fetch the latest changes of this stack.

Expand Down
13 changes: 9 additions & 4 deletions make/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ docker-fetch: ## Fetch smartbooster/symfony-docker stack files
git remote add docker git@github.com:smartbooster/symfony-docker.git
git fetch docker
git checkout docker/main .
make docker-generate-lock
git remote remove docker
make docker-post-fetch
df: docker-fetch ## Alias for docker-fetch

.PHONY: docker-generate-lock
docker-generate-lock: ## Generate the symfony-docker.lock to track which version of the stack is install on the project
rm -f symfony-docker.lock
touch symfony-docker.lock
echo -n 'hash: ' >> symfony-docker.lock
git rev-parse docker/main >> symfony-docker.lock
echo 'fetch_time: '$(shell date +%Y-%m-%dT%H:%M:%S) >> symfony-docker.lock
echo -n 'version: ' >> symfony-docker.lock
git rev-parse docker/main | xargs git tag --contains >> symfony-docker.lock
git remote remove docker
make docker-post-fetch
df: docker-fetch ## Alias for docker-fetch

.PHONY: docker-post-fetch
docker-post-fetch: ## Post smartbooster/symfony-docker fetch process to clean unwanted files to be sync
git restore --staged .env.skeleton
rm -rf .github
rm -f .env.skeleton
git restore --staged package.json
git restore package.json
Expand All @@ -36,6 +39,8 @@ docker-post-fetch: ## Post smartbooster/symfony-docker fetch process to clean un
git restore .gitlab-ci.yml
git restore --staged docs
rm -r docs
git restore --staged .github
rm -rf .github
echo Fetch smartbooster/symfony-docker complete!

.PHONY: check-missing-env
Expand Down
3 changes: 2 additions & 1 deletion make/install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ remove-symfony: ## Remove all symfony related files of the repository
phpcs.xml \
phpstan.neon \
phpunit.xml.dist \
symfony.lock
symfony.lock \
symfony-docker.lock

.PHONY: install
install: ## Install the project. MUST BY RUN OUTSIDE OF THE DOCKER CONTAINER !
Expand Down

0 comments on commit b4b5ceb

Please sign in to comment.