From 79690f2edb5a4fb9992170320960b1b94eaa6ad1 Mon Sep 17 00:00:00 2001 From: Adam Lavin Date: Sat, 27 Mar 2021 03:58:08 +0000 Subject: [PATCH] Add missing files --- .dockerignore | 2 ++ Dockerfile | 65 ++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile.dev | 13 ++++++++++ docker-compose.yml | 48 ++++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 Dockerfile.dev create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..7e5da87a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules/ +vendor/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..1398d9db --- /dev/null +++ b/Dockerfile @@ -0,0 +1,65 @@ +FROM jrottenberg/ffmpeg:4.3-alpine312 as ffmpeg +FROM node:12-alpine as assets_builder + +# To handle 'not get uid/gid' +RUN npm config set unsafe-perm true + +RUN npm install -g gulp + +WORKDIR /app + +RUN mkdir -p /app/resources + +COPY package.json /app + +RUN npm install + +COPY gulpfile.js /app +COPY webpack.base.config.js /app +COPY webpack.dev.config.js /app +COPY webpack.production.config.js /app +COPY resources /app/resources + +RUN gulp build + +FROM php:8.0-fpm-alpine + +ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 + +COPY --from=ffmpeg /usr/local /usr/local +COPY --from=composer /usr/bin/composer /usr/bin/composer +COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/install-php-extensions + +## Common libraries required for ffmpeg to work +RUN apk add --no-cache libgcc libstdc++ ca-certificates libcrypto1.1 libssl1.1 libgomp expat git +RUN apk add --no-cache nginx sudo + +# Install php extensions +RUN install-php-extensions mysqli pgsql pdo_mysql pdo_pgsql gmp gmagick + +RUN mkdir /app && chown -R www-data: /app + +USER www-data +WORKDIR /app + +COPY --chown=www-data composer.json /app +COPY --chown=www-data composer.lock /app + +RUN composer install --no-scripts --no-autoloader --ignore-platform-reqs + +COPY --chown=www-data --from=assets_builder /app /app +COPY --chown=www-data . /app + +RUN composer dump-autoload -o +RUN php artisan optimize + +USER root + +# Remove files no longer needed on the host +RUN rm /usr/bin/composer /usr/bin/install-php-extensions + +COPY docker/nginx/site.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 + +ENTRYPOINT ["docker/entrypoint.sh"] diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 00000000..95d65c44 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,13 @@ +FROM ponyfm + +COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/install-php-extensions + +RUN install-php-extensions xdebug + +RUN echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.remote_port=9001" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.remote_handler=dbgp" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.idekey=phpstorm" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.remote_host=docker.for.mac.localhost" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..b289a1fe --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,48 @@ +version: "3.8" + +services: + web: + image: ponyfm + container_name: web + ports: + - "8000:80" + links: + - elasticsearch + - postgresd + command: + - web + volumes: + - .:/app + - ./vagrant/php-overrides.ini:/usr/local/etc/php/conf.d/php.ini:ro + - ./vagrant/php-overrides.ini:/usr/local/etc/php-fpm.d/php.ini:ro + + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0 + container_name: elasticsearch + environment: + - "discovery.type=single-node" + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + ulimits: + memlock: + soft: -1 + hard: -1 + volumes: + - elasticsearch-data:/usr/share/elasticsearch/data + ports: + - "9200:9200" + + postgresd: + image: postgres:13.1-alpine + ports: + - "5432:5432" + environment: + - POSTGRES_USER=app + - POSTGRES_PASSWORD=secret + - POSTGRES_DB=app + volumes: + - postgres-data:/var/lib/postgresql/data + + +volumes: + postgres-data: + elasticsearch-data: