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

Deploy api-platform 2.6 with docker #1859

Closed
d0niek opened this issue Mar 24, 2021 · 2 comments
Closed

Deploy api-platform 2.6 with docker #1859

d0niek opened this issue Mar 24, 2021 · 2 comments

Comments

@d0niek
Copy link

d0niek commented Mar 24, 2021

Hi!

Deploy with docker to version 2.5 was easy with https://github.com/api-platform/docker-compose-prod

On local:

vim .env
docker-compose -f docker-compose.build.yml build --pull
docker-compose -f docker-compose.build.yml push

On server:

vim .env
docker-compose pull
docker-compose up -d
docker-compose exec php bin/console cache:clear && docker-compose restart php

How should I do it with version 2.6? Which docker-compose* file(s) use for build/push, which docker-compose* file(s) use for pull/up?

For example file docker-compose.override.yml expose caddy ports so it looks good for docker-compose up -d but it uses build target dev for pwa and bind local directory for php.

@d0niek
Copy link
Author

d0niek commented Mar 24, 2021

Ok, I see there was an update in 2.6.3 version and now I think it should looks like:

On local:

vim .env
docker-compose -f docker-compose.yml -f docker-compose.prod.yml build --pull
docker-compose -f docker-compose.yml -f docker-compose.prod.yml push

On server:

vim .env
docker-compose -f docker-compose.yml -f docker-compose.prod.yml pull
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d

Am I correct? :-)

Those tow commands are equals and are for development time (?):

docker-compose $docker_command
docker-compose -f docker-compose.yml -f docker-compose.override.yml $docker_command

@jlagneau
Copy link

jlagneau commented Mar 28, 2021

Yes, that's the correct way to deploy.

And yes too, you don't need to specify docker-compose.override.yml for development, you can just use docker-compose normally, read docker-compose docs.

https://docs.docker.com/compose/production/
https://docs.docker.com/compose/extends/

By default, Compose reads two files, a docker-compose.yml and an optional docker-compose.override.yml file. By convention, the docker-compose.yml contains your base configuration. The override file, as its name implies, can contain configuration overrides for existing services or entirely new services.

In this case, the override file contains the development configuration.

The process for deploying in production in 2.5 was slightly more complicated than that, there was an external repository for production api-platform/docker-compose-prod but it was archived and is no longer relevant.

@d0niek d0niek closed this as completed Apr 6, 2021
d0niek added a commit to d0niek/api-platform that referenced this issue Jul 8, 2021
According to this issue api-platform#1859 to run docker-compose on production we
have to run command like
`docker-compose -f docker-compose.yml -f docker-compose.prod.yml ...`.

With setting up an env COMPOSE_FILE we don't have to prefix docker
commands with compose files.

See https://docs.docker.com/compose/reference/envvars/#compose_file
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

No branches or pull requests

2 participants