Install for Free

Chrome Extension for ChatGPT


DevOps / Containerization


7 months ago



Create a docker-compose and variable file for deployment of an application.

Prompt Hint

docker, compose, homelab, deployment, container, ci/cd, network


Learn more about the latest prompt: Docker-Compose Get the details such as Create a docker-compose and variable file for deployment of an application.

Prompt Description

Sure! Here's an example of a docker-compose.yml file and a .env file for deploying an application using Docker Compose: docker-compose.yml: ```yaml version: '3' services: web: image: nginx:latest ports: - ${APP_PORT}:80 environment: - APP_ENV=${APP_ENV} volumes: - ./app:/usr/share/nginx/html db: image: mysql:latest environment: - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD} - MYSQL_DATABASE=${DB_NAME} - MYSQL_USER=${DB_USER} - MYSQL_PASSWORD=${DB_PASSWORD} volumes: - db_data:/var/lib/mysql volumes: db_data: ``` .env file: ``` APP_PORT=8080 APP_ENV=production DB_ROOT_PASSWORD=secret DB_NAME=myapp DB_USER=myuser DB_PASSWORD=mypassword ``` In this example, we have two services: "web" and "db". The "web" service uses the nginx image and maps the specified APP_PORT to port 80 inside the container. The APP_ENV environment variable is also set to the value specified in the .env file. The web service also mounts the ./app directory to /usr/share/nginx/html inside the container. The "db" service uses the mysql image and sets the necessary environment variables for configuring the database. The db service also mounts a volume called "db_data" to persist the MySQL data. The .env file contains the values for the environment variables used in the docker-compose.yml file. To deploy the application, you can run the following command: ``` docker-compose up -d ``` This will start the services defined in the docker-compose.yml file in detached mode.

Please note: The preceding description has not been reviewed for accuracy. For the best understanding of what will be generated, we recommend installing AIPRM for free and trying out the prompt.

Output Example

Coming soon...