Skip to content

Updating docker-compose for production #1333

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

Merged
merged 2 commits into from
Jul 7, 2021
Merged

Updating docker-compose for production #1333

merged 2 commits into from
Jul 7, 2021

Conversation

jdutheil
Copy link
Contributor

@jdutheil jdutheil commented Apr 2, 2021

Hi,

Here is an updated version of the documentation for ApiPlatform 2.6, current one is reflecting ApiPlatform 2.5. I struggled a bit to deploy in production, and finally came across that so I think that would be good for future users.

I think there are environment variables missing, I needed only those ones and didn't have time to make further testing. So be free to add those you know !

@alanpoulain alanpoulain requested a review from dunglas April 2, 2021 08:58
@@ -12,21 +12,10 @@ e.g. [Docker Hub](https://hub.docker.com/), [Google Container Registry](https://
would pull the pre-built images from the container registry. This maintains a separation of concerns between the build
environment and the production environment.

## Installing the Docker Compose Setup for Production
## Deploying for production for ApiPlatorm 2.6
Copy link
Contributor

Choose a reason for hiding this comment

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

API Platform

@Chris53897
Copy link
Contributor

I had a lot of struggle myself to figure out how it works on v. 2.6. So i hope this will be reviewed shortly and will help a lot of users for a better start to API-Platform

Copy link
Contributor

@michael-schaefer-eu michael-schaefer-eu left a comment

Choose a reason for hiding this comment

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

typo fix

If you are using the [API Platform Distribution](../distribution/index.md), we provide a [ready-to-deploy Docker Compose
setup for production](https://github.com/api-platform/docker-compose-prod), with (optional) [Let's Encrypt](https://letsencrypt.org/)
integration.
Thanks to ApiPlatform 2.6, the deploiement process has never been so easy. The required docker-compose files are already there, and you just have to pass the docker-compose.prod.yml to docker-compose to build images for production.
Copy link
Contributor

Choose a reason for hiding this comment

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

deploiement -> deployment

@alanpoulain alanpoulain changed the title Updating doc Updating docker-compose for production Apr 8, 2021
@@ -12,21 +12,10 @@ e.g. [Docker Hub](https://hub.docker.com/), [Google Container Registry](https://
would pull the pre-built images from the container registry. This maintains a separation of concerns between the build
environment and the production environment.

## Installing the Docker Compose Setup for Production
## Deploying for production for ApiPlatorm 2.6
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## Deploying for production for ApiPlatorm 2.6
## Deploying for Production

If you are using the [API Platform Distribution](../distribution/index.md), we provide a [ready-to-deploy Docker Compose
setup for production](https://github.com/api-platform/docker-compose-prod), with (optional) [Let's Encrypt](https://letsencrypt.org/)
integration.
Thanks to ApiPlatform 2.6, the deploiement process has never been so easy. The required docker-compose files are already there, and you just have to pass the docker-compose.prod.yml to docker-compose to build images for production.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Thanks to ApiPlatform 2.6, the deploiement process has never been so easy. The required docker-compose files are already there, and you just have to pass the docker-compose.prod.yml to docker-compose to build images for production.
To build images for production, you have to use the `docker-compose.prod.yml` file with Docker Compose.


If you are **not** using the (optional) Let's Encrypt integration:
Let's Encrypt integration is now automatic, thanks to Caddy Server:
Copy link
Member

Choose a reason for hiding this comment

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

You can remove this comment.

TRUSTED_HOSTS=^(?:localhost|api|api\.example\.com)$
VARNISH_IMAGE=registry.example.com/api-platform/varnish
MERCURE_PUBLISHER_JWT_KEY=someKey
MERCURE_SUBSCRIBER_JWT_KEY=someKey
Copy link

@Antarian Antarian May 8, 2021

Choose a reason for hiding this comment

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

Would be worth to mention, that you need also update docker-compose.yml file database section to use bind volume. Otherwise you are at risk to override all your production data.
Also environment variable SERVER_NAME set in docker compose.yml may be different in production.

Thinking if documentation is the place to inform to change these, or API-Platform 2.6 docker-compose needs more work to be production ready. Like moving DB volume setting and some variables (POSTGRES_PASSWORD) to environment or to .override and .prod respectively.

Copy link
Member

Choose a reason for hiding this comment

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

Hello,
I think that the Docker Compose configuration needs some work for the database indeed to be usable in production.
Are you willing to make a PR?

@alanpoulain alanpoulain merged commit af92c75 into api-platform:2.6 Jul 7, 2021
@alanpoulain
Copy link
Member

Thank you!

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 this pull request may close these issues.

5 participants