From 8ae348ce9676713bd548e8814ff90ea7da4f6552 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Mon, 4 Jul 2022 18:40:15 +0700 Subject: [PATCH] redo containerization --- Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 36 ++++++++++++++++++++++++++++++++++++ docker/Dockerfile | 32 -------------------------------- 3 files changed, 78 insertions(+), 32 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml delete mode 100644 docker/Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3984a02 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM php:7.4-fpm-alpine + +RUN apk add --update libzip-dev curl-dev &&\ + docker-php-ext-install curl && \ + apk del gcc g++ &&\ + rm -rf /var/cache/apk/* + +RUN apk add --no-cache \ + zlib-dev \ + icu-dev \ + libpng-dev \ + oniguruma-dev \ + libpq-dev + +RUN docker-php-ext-install \ + curl \ + mbstring \ + intl \ + pdo \ + pdo_pgsql \ + pgsql \ + tokenizer + +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +RUN rm -rf /var/cache/apk/* + +WORKDIR /var/www + +COPY composer.json composer.lock ./ + +COPY . . + +RUN chmod +x artisan + +RUN composer install + +RUN composer dump-autoload --optimize + +EXPOSE 80 + +CMD php -S 0.0.0.0:80 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7a0ec5d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,36 @@ +version: '3.8' +services: + lumen: + build: + context: . + dockerfile: Dockerfile + extra_hosts: + - 'host.docker.internal:host-gateway' + ports: + - '${APP_PORT:-80}:80' + volumes: + - .:/var/www + networks: + - ospro + healthcheck: + test: curl --fail http://localhost || exit 1 + interval: 60s + retries: 5 + start_period: 20s + timeout: 10s + db: + image: postgres:14.4-alpine + restart: always + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + ports: + - '5432:5432' + volumes: + - db:/var/lib/postgresql/data +networks: + ospro: + driver: bridge +volumes: + db: + driver: local diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 35ca14e..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -FROM php:7.4-fpm-alpine - -RUN apk add --update --no-cache -RUN apk add \ - libpq-dev \ - php7-tokenizer \ - php7-zip \ - php7-curl \ - php7-mbstring \ - php7-intl \ - php7-iconv -RUN docker-php-ext-install pgsql pdo_pgsql - -#RUN curl -sS https://getcomposer.org/installer | php -- \ -# --install-dir=/usr/bin --filename=composer - -ADD https://getcomposer.org/installer ./composer-setup.php -RUN php ./composer-setup.php --install-dir=/usr/local/bin --filename=composer -RUN rm ./composer-setup.php - - -RUN rm -rf /var/cache/apk/* - -COPY . /kit-api - -RUN cd "/kit-api" && cp .env.production .env && composer install - -WORKDIR /kit-api - -EXPOSE 80 - -CMD php -S 0.0.0.0:80