Skip to content

Instantly share code, notes, and snippets.

@erfansahaf
Created May 25, 2020 14:49
Show Gist options
  • Save erfansahaf/d46745c818c3e5c168d93bab3181af2e to your computer and use it in GitHub Desktop.
Save erfansahaf/d46745c818c3e5c168d93bab3181af2e to your computer and use it in GitHub Desktop.
version: '3.5'
services:
application:
build:
context: ./application
dockerfile: Dockerfile
args:
- PHP_VERSION=7.4
- TIDEWAYS_CONNECTION=tcp://tideways:9135
- TIDEWAYS_APIKEY=Wgu358OR0pU6zsJn
- TIDEWAYS_SAMPLERATE=100
ports:
- 3000:80
- 9253:9253
tideways:
image: docker.io/sroze/tideways
ARG PHP_VERSION=7.4
FROM php:${PHP_VERSION}-fpm
# Add user for application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Install PHP Extensions
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libgmp3-dev \
libzip-dev \
libonig-dev \
vim \
git \
curl \
zip \
procps \
wget \
&& docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd gmp \
&& docker-php-ext-install pdo pdo_mysql mysqli mbstring zip exif pcntl
# Copy PHP-FPM configs
COPY ./php/php-fpm.d/*.conf /usr/local/etc/php-fpm.d/
COPY ./php/conf.d/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
# Install NGINX
RUN apt-get install -y nginx
# Copy Nginx Configs
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
COPY ./nginx/conf.d/*.conf /etc/nginx/conf.d/
# Forward Nginx request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/stdout-access.log \
&& ln -sf /dev/stderr /var/log/nginx/stderr-error.log
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
composer global require hirak/prestissimo
COPY .env ${PROJECT_PATH}/.env
COPY oauth-private.key ${PROJECT_PATH}/storage/oauth-private.key
COPY oauth-public.key ${PROJECT_PATH}/storage/oauth-public.key
RUN echo 'deb http://s3-eu-west-1.amazonaws.com/tideways/packages debian main' > /etc/apt/sources.list.d/tideways.list && \
apt-get install -y gnupg && \
curl -sS 'https://s3-eu-west-1.amazonaws.com/tideways/packages/EEB5E8F4.gpg' | apt-key add - && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -yq install tideways-php
ARG TIDEWAYS_CONNECTION
ARG TIDEWAYS_APIKEY
ARG TIDEWAYS_SAMPLERATE
RUN echo 'extension=tideways.so\ntideways.connection=${TIDEWAYS_CONNECTION}\ntideways.api_key=${TIDEWAYS_APIKEY}\ntideways.samplerate=${TIDEWAYS_SAMPLERATE}' > /usr/local/etc/php/conf.d/40-tideways.ini
# Clear package manager cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
EXPOSE 80
WORKDIR ${PROJECT_PATH}
COPY ./docker-entrypoint.sh /root
ENTRYPOINT /root/docker-entrypoint.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment