Created
December 18, 2024 20:30
-
-
Save baran/192a998c6a9e3fdfaeda7632a3e931c5 to your computer and use it in GitHub Desktop.
DockerCompose ile Postgresql ve PHP kullanımı
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| services: | |
| php: | |
| build: | |
| context: . | |
| dockerfile: Dockerfile | |
| image: my-php-app | |
| container_name: php_app | |
| volumes: | |
| - .:/var/www/html | |
| ports: | |
| - "9000:9000" | |
| networks: | |
| - app-network | |
| environment: | |
| - DB_HOST=postgres | |
| - DB_PORT=5432 | |
| - DB_USER=postgres | |
| - DB_PASSWORD=password | |
| - DB_NAME=mydatabase | |
| postgres: | |
| image: postgres:latest | |
| container_name: postgres_db | |
| environment: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: password | |
| POSTGRES_DB: mydatabase | |
| ports: | |
| - "5432:5432" | |
| volumes: | |
| - postgres_data:/var/lib/postgresql/data | |
| networks: | |
| - app-network | |
| networks: | |
| app-network: | |
| driver: bridge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # PHP ve PostgreSQL ile çalışan bir uygulama için Dockerfile | |
| FROM php:8.2-fpm | |
| # Uygulamanın çalışacağı ortam değişkenleri | |
| ENV APP_ENV=production | |
| # PHP sürümüne bağlı paketlerin yüklenmesi | |
| RUN apt-get update && apt-get install -y \ | |
| libpng-dev \ | |
| libjpeg-dev \ | |
| libfreetype6-dev \ | |
| zip \ | |
| git \ | |
| zlib1g-dev \ | |
| libicu-dev \ | |
| libmcrypt-dev \ | |
| libssl-dev \ | |
| g++ \ | |
| && docker-php-ext-configure gd --with-freetype --with-jpeg \ | |
| && docker-php-ext-install pdo pdo_pgsql mysqli mbstring exif zip intl sockets \ | |
| && pecl install mcrypt-1.0.4 \ | |
| && docker-php-ext-enable mcrypt | |
| # Uygulama kodlarının bulunduğu klasörü belirtiyoruz | |
| WORKDIR /var/www/html | |
| # Uygulama kodlarını buraya kopyalıyoruz | |
| COPY . /var/www/html/ | |
| # Varsayılan port ayarı | |
| EXPOSE 9000 | |
| # php-fpm çalıştırıyoruz | |
| CMD ["php-fpm"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment