# Docker

## Dockerizar una aplicación

Puedes dockerizar tu aplicación utilizando unas simples instrucciones en un `Dockerfile` y un `docker-compose.yml`

El siguiente `Dockerfile` es un ejemplo utilizando `postgres`

```bash
FROM php:7.2-apache
COPY . /var/www/html/cloudcsv_api

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y git \
    -y libpq-dev \
    zip \
    unzip

# PDO driver
RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql
RUN docker-php-ext-install pdo pdo_pgsql

#Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN a2enmod rewrite

WORKDIR /var/www/html/cloudcsv_api
RUN composer install
```

A continuación ya solo nos falta crear nuestro `docker-compose.yml`

```yaml
version: '3'
services:
  web:
    image: php:7.2-apache
    build: .
    depends_on:
      - db
    ports:
      - 8081:80
      
  db:
    image: postgres:9.6
    restart: always
    environment:
      POSTGRES_USER: ${USER}
      POSTGRES_PASSWORD: ${PASSWORD}
      POSTGRES_DB: ${DB_NAME}
    volumes:
      - ./etc/init_db.sql:/docker-entrypoint-initdb.d/init_db.sql
    ports:
      - 5432:5432

  adminer:
    image: adminer
    restart: always
    ports:
      - 9090:8080

volumes:
  db:
```

En el ejemplo anterior tenemos un `docker-compo.yml` que contiene una base de datos en `Postgres` con `Adminer` incluido para administrar la base de datos.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ligne-framework.gitbook.io/ligne-framework-php/extra/docker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
