Skip to content
Snippets Groups Projects
Commit f88495f4 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

docker-compose setup

parent f0b08618
No related branches found
No related tags found
No related merge requests found
......@@ -39,4 +39,4 @@ APP_BUILDINFO=unknown # a git hash or something identifying the build
APP_BUILDINFO_URL='#'
# Disable the webserver bundle (avoids deprecation warnings). Use docker instead.
DISABLE_DEV_SERVER=false
\ No newline at end of file
DISABLE_DEV_SERVER=true
\ No newline at end of file
# Running with Docker
This is simple docker-compose setup using docker with php-fpm and nginx to serve
the symfony app.
## Setup
* `sudo apt install docker-compose` to install docker-compose on Debian/Ubuntu
## Running the Server
* `sudo docker-compose up -d` to start the server in the background
* `sudo docker-compose up` to start the server in the foreground with logs
* `sudo docker-compose stop` to stop the server
* `sudo docker-compose logs -f` to see the logs
* `sudo docker-compose restart messenger-worker` restart messenger worker for updating message handling code
## Executing Symfony commands
* `./run` to start a shell in the php-fpm container.
* After this you can run symfony/composer commands like:
* `./bin/console debug:config`
* `composer install`
* `composer test`
* You can also call `bin/console` commands directly from outside the container with `./console debug:config`
if you have all dependencies available on the host.
## Links
* Open <http://127.0.0.1:8000/> for the API Platform webpage
* Open <http://localhost:8101/> for redis commander
version: "3.1"
services:
webserver:
image: nginx:alpine
working_dir: /application
volumes:
- ..:/application
- ./webserver/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- "8000:80"
php-fpm:
environment:
- TERM_PROGRAM=Hyper # force colors for the symfony dumper
build:
context: php-fpm
working_dir: /application
volumes:
- ..:/application
- ./php-fpm/php-ini-overrides.ini:/etc/php/7.3/fpm/conf.d/99-overrides.ini
- ./php-fpm/php-fpm-overrides.conf:/etc/php/7.3/fpm/pool.d/z-overrides.conf
messenger-worker:
environment:
- TERM_PROGRAM=Hyper # force colors for the symfony dumper
build:
context: php-fpm
working_dir: /application
entrypoint: ./bin/console messenger:consume async
volumes:
- ..:/application
- ./php-fpm/php-ini-overrides.ini:/etc/php/7.3/cli/conf.d/99-overrides.ini
redis:
image: "redis"
redis-commander:
image: "rediscommander/redis-commander"
environment:
- REDIS_HOST=redis
ports:
- "8101:8081"
\ No newline at end of file
FROM debian:buster
ENV DEBIAN_FRONTEND=noninteractive
# Basics
RUN apt-get update && apt-get install -y wget lsb-release
# Install PHP and the rest
# Debian Buster only has php-redis 4.2, we need 4.3
RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg \
&& echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list \
&& apt-get update \
&& apt-get -y --no-install-recommends install \
ca-certificates \
curl \
unzip \
sudo \
git \
php-apcu \
php-apcu-bc \
php7.3-cli \
php7.3-curl \
php7.3-soap \
php7.3-json \
php7.3-mbstring \
php7.3-opcache \
php7.3-readline \
php7.3-xml \
php7.3-zip \
php7.3-redis \
php7.3-fpm \
php7.3-ldap \
php7.3-gmp \
php7.3-xdebug \
composer \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
STOPSIGNAL SIGQUIT
RUN useradd -u 1000 -ms /bin/bash user
RUN echo 'user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER user
RUN git config --global url."https://gitlab.tugraz.at/".insteadOf "git@gitlab.tugraz.at:"
CMD ["/usr/sbin/php-fpm7.3", "-O" ]
EXPOSE 9000
WORKDIR "/application"
\ No newline at end of file
[global]
; Override default pid file
pid = /home/user/.php-fpm.pid
; Avoid logs being sent to syslog
error_log = /proc/self/fd/2
; Set this to php default's max_execution_time to allow children to stop gracefully when fpm is commanded to stop
; This helps avoiding 502's
process_control_timeout = 30
; Do not daemonize (eg send process to the background)
daemonize = no
; Don't print anything when started
log_level = warning
[www]
; Access from webserver container is via network, not socket file
listen = [::]:9000
; Redirect logs to stdout - FPM closes /dev/std* on startup
access.log = /proc/self/fd/2
access.format = "[%{%Y-%m-%d %H:%M:%S}t] %m %{REQUEST_SCHEME}e://%{HTTP_HOST}e%{REQUEST_URI}e CODE=%s"
catch_workers_output = yes
; Remove "pool www" decoration from log output
decorate_workers_output = no
; This option sets the limit on the number of simultaneous requests that will be served
pm.max_children = 10
\ No newline at end of file
upload_max_filesize = 200M
post_max_size = 208M
memory_limit = 450M
zend.assertions = 1
date.timezone = "Europe/Vienna"
#!/bin/sh
docker-compose run --rm --entrypoint bash php-fpm
server {
listen 80 default;
client_max_body_size 108M;
access_log /var/log/nginx/application.access.log;
root /application/public;
index index.php;
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
location ~ (\.php|/)$ {
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log";
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
include fastcgi_params;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment