Skip to content

Commit aee6e98

Browse files
committed
chore: add new docker compose
1 parent db6e94b commit aee6e98

12 files changed

+360
-41
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,5 @@ software/css
122122
speaker_bureau/css
123123
registration/css
124124
/summit-trackchair-app/css/
125+
/.env
126+
/docker-compose/mysql/model/*.sql

Dockerfile

Lines changed: 70 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,70 @@
1-
FROM ubuntu:14.04.5
2-
3-
MAINTAINER Sebastian Marcet <smarcet@gmail.com>
4-
5-
ENV container docker
6-
ENV DEFAULT_LOCALE en_US
7-
# let the container know that there is no tty
8-
ENV DEBIAN_FRONTEND noninteractive
9-
10-
#Optional, update mirrors speedups updates, but some mirrors sometimes fail
11-
#RUN sed -i -e 's,http://[^ ]*,mirror://mirrors.ubuntu.com/mirrors.txt,' /etc/apt/sources.list
12-
13-
#update apt sources
14-
RUN apt-get update --fix-missing
15-
16-
#install required packages
17-
RUN apt-get --no-install-recommends install -y apt-utils openssh-server sudo curl wget nfs-common puppet puppet-common && \
18-
apt-get clean #cleanup to reduce image size
19-
20-
# Create and configure vagrant user
21-
RUN useradd --create-home -s /bin/bash vagrant
22-
WORKDIR /home/vagrant
23-
# fix --force-yes issue on apt-get install
24-
RUN echo 'APT::Get::Assume-Yes "true"; \n\
25-
APT::Get::force-yes "true";' > /etc/apt/apt.conf.d/99forceyesconf
26-
# Configure SSH access
27-
RUN mkdir -p /home/vagrant/.ssh && \
28-
echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" > /home/vagrant/.ssh/authorized_keys && \
29-
chown -R vagrant: /home/vagrant/.ssh && \
30-
adduser vagrant sudo && \
31-
`# Enable passwordless sudo for users under the "sudo" group` && \
32-
sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers && \
33-
echo -n 'vagrant:vagrant' | chpasswd && \
34-
`# Thanks to http://docs.docker.io/en/latest/examples/running_ssh_service/` && \
35-
mkdir /var/run/sshd
36-
37-
# Expose ports
38-
EXPOSE 80
39-
#leave the SHH daemon (and container) running
40-
CMD /usr/sbin/sshd -D
1+
FROM php:7.2-fpm
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
ARG NVM_VERSION="v0.39.7"
5+
ARG GITHUB_OAUTH_TOKEN
6+
ARG XDEBUG_VERSION="xdebug-3.1.6"
7+
8+
ENV NVM_VERSION=$NVM_VERSION
9+
ENV NODE_VERSION="12.22.12"
10+
ENV NVM_DIR=/root/.nvm
11+
ENV COMPOSER_ALLOW_SUPERUSER=1
12+
ENV GITHUB_OAUTH_TOKEN=$GITHUB_OAUTH_TOKEN
13+
ENV PHP_DIR /usr/local/etc/php
14+
15+
# base packages
16+
RUN apt-get update && apt-get install -y \
17+
git \
18+
curl \
19+
libpng-dev \
20+
libonig-dev \
21+
libxml2-dev \
22+
zip \
23+
unzip \
24+
redis-tools \
25+
nano \
26+
python3 \
27+
make \
28+
g++\
29+
gpg \
30+
gettext \
31+
libgmp-dev
32+
33+
RUN apt clean && rm -rf /var/lib/apt/lists/*
34+
35+
RUN docker-php-ext-install mbstring exif pcntl bcmath sockets gettext gmp gd mysqli
36+
RUN docker-php-ext-enable gd mysqli
37+
# XDEBUG
38+
RUN yes | pecl install ${XDEBUG_VERSION}
39+
COPY docker-compose/php/docker-php-ext-xdebug.ini $PHP_DIR/conf.d/docker-php-ext-xdebug.ini
40+
41+
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
42+
RUN echo 'memory_limit = 512M' >> $PHP_INI_DIR/php.ini;
43+
44+
# nvm
45+
46+
RUN mkdir $NVM_DIR \
47+
&& curl https://raw.githubusercontent.com/creationix/nvm/$NVM_VERSION/install.sh | bash \
48+
&& . $NVM_DIR/nvm.sh \
49+
&& nvm install $NODE_VERSION \
50+
&& nvm alias default $NODE_VERSION \
51+
&& nvm use default
52+
53+
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
54+
ENV PATH $NVM_DIR/v$NODE_VERSION/bin:$PATH
55+
56+
# yarn
57+
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
58+
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
59+
RUN apt update && apt install -y yarn
60+
61+
# install node
62+
RUN curl -fsSL https://deb.nodesource.com/setup_12.x | bash -
63+
RUN apt-get install -y nodejs
64+
65+
WORKDIR /var/www
66+
COPY . /var/www
67+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
68+
69+
RUN composer config -g github-oauth.github.com $GITHUB_OAUTH_TOKEN
70+
RUN git config --global --add safe.directory /var/www

LOCAL_DEVELOPMENT_HOWTO.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Run Local Dev Server
2+
====================
3+
4+
1. Create [.env](.env) file with following properties
5+
```dotenv
6+
GITHUB_OAUTH_TOKEN="<GITHUB TOKEN FROM YOUR GITHUB ACCOUNT>"
7+
8+
SS_DB_HOST=db_model
9+
SS_DATABASE=model
10+
SS_DB_USERNAME=root
11+
SS_DB_PASSWORD=1qaz2wsx
12+
13+
REDIS_HOST=redis
14+
REDIS_PORT=6379
15+
REDIS_DB=0
16+
REDIS_PASSWORD=1qaz2wsx!
17+
REDIS_DATABASES=16
18+
```
19+
2. Create a [_ss_environment.php](_ss_environment.php) file with follwing properties
20+
```php
21+
<?php
22+
/* What kind of environment is this: development, test, or live (ie, production)? */
23+
define('SS_ENVIRONMENT_TYPE', 'dev');
24+
25+
/* Database connection */
26+
define('SS_DATABASE_SERVER', 'db_model');
27+
define('SS_DATABASE_USERNAME', 'root');
28+
define('SS_DATABASE_PASSWORD', '1qaz2wsx');
29+
define('SS_DATABASE_CLASS','CustomMySQLDatabase');
30+
/* Global variables */
31+
$database = 'model';
32+
$email_from = '<YOUR EMAIL>';
33+
$email_log = '<YOUR EMAIL>';
34+
define('SMTPMAILER_SMTP_SERVER_ADDRESS', 'smtp.sendgrid.net'); # SMTP server address
35+
define('SMTPMAILER_DO_AUTHENTICATE', true); # Turn on SMTP server authentication. Set to false for an anonymous connection
36+
define('SMTPMAILER_USERNAME', ''); # SMTP server username, if SMTPAUTH == true
37+
define('SMTPMAILER_PASSWORD', ''); # SMTP server password, if SMTPAUTH == true
38+
define('SENDGRID_API_KEY', '<SENDGRID API KEY>');
39+
```
40+
3. Drop here [docker-compose/mysql/model](docker-compose/mysql/model) the database dump *.sql file
41+
4. Install docker and docker compose see
42+
[https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-22-04](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-22-04) and [https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-22-04](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-22-04)
43+
5. Run script ./start_local_server.sh
44+
45+
Useful Commands
46+
===============
47+
48+
check containers health status
49+
50+
````bash
51+
docker inspect --format "{{json .State.Health }}" www-openstack-model-db-local | jq '.
52+
````
53+

PHPSTORM_DOCKER_CONFIG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Debug config at PHPSTORM
2+
==========================
3+
4+
1. Add a new CLI interpreter using [Docker]
5+
1. choose image www-openstack:latest
6+
2. click [OK]
7+
3. select new CLI interpreter
8+
4. click [Apply]
9+
10+
2. Edit network settings at container
11+
1. goto Settings->PHP and locate "Docker Container" input.
12+
2. Click on Folder icon.
13+
3. a new popup titled "Edit Docker Container Settings" will open.
14+
4. fill the "Network Mode" input with the bridge name, to find it out run ```$docker network list``` command.
15+
and put the name of the bridge there.
16+
17+
3. Create new server
18+
1. goto Settings->PHP->Servers
19+
2. click on [+]
20+
3. fill up Name with "Docker"
21+
4. fill up Host with "0.0.0.0"
22+
5. fill up Port with "80"
23+
6. click use map mappings
24+
7. map root to /var/www
25+
26+
4. Create a remote debug configuration profile
27+
1. goto Run->Debug->Edit Configurations
28+
2. create a new "PHP Remote debug" Profile
29+
3. set name as "Docker"
30+
4. check "Filter debug connection by IDE key"
31+
5. set IDE KEY as "PHPSTORM"
32+
6. set Server as "Docker"

delete_local_server.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -e
3+
export DOCKER_SCAN_SUGGEST=false
4+
5+
docker compose down
6+
docker compose build --no-cache
7+
docker compose up -d --build --force-recreate

docker-compose.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
services:
2+
app:
3+
build:
4+
context: ./
5+
dockerfile: Dockerfile
6+
args:
7+
GITHUB_OAUTH_TOKEN: ${GITHUB_OAUTH_TOKEN}
8+
extra_hosts:
9+
- "host.docker.internal:host-gateway"
10+
image: www-openstack
11+
container_name: www-openstack
12+
restart: unless-stopped
13+
working_dir: /var/www/
14+
volumes:
15+
- ./:/var/www
16+
networks:
17+
- www-openstack-local-net
18+
depends_on:
19+
redis:
20+
condition: service_started
21+
db_model:
22+
condition: service_healthy
23+
redis:
24+
image: redis:latest
25+
container_name: redis-www-openstack
26+
restart: always
27+
command: redis-server --save 20 1 --loglevel warning --requirepass ${REDIS_PASSWORD}
28+
ports:
29+
- ${REDIS_PORT}
30+
volumes:
31+
- /tmp/www-openstack/redis:/root/redis
32+
- ./docker-compose/redis/redis.conf:/usr/local/etc/redis/redis.conf
33+
networks:
34+
- www-openstack-local-net
35+
env_file: ./.env
36+
db_model:
37+
image: mysql:8.0
38+
container_name: www-openstack-model-db-local
39+
command: --default-authentication-plugin=mysql_native_password --sql_mode=NO_ENGINE_SUBSTITUTION
40+
restart: unless-stopped
41+
ports:
42+
- "32010:3306"
43+
environment:
44+
MYSQL_DATABASE: ${SS_DATABASE}
45+
MYSQL_PASSWORD: ${SS_DB_PASSWORD}
46+
MYSQL_ROOT_PASSWORD: ${SS_DB_PASSWORD}
47+
SERVICE_TAGS: dev
48+
SERVICE_NAME: mysql
49+
healthcheck:
50+
test: mysql -u ${SS_DB_USERNAME} --password=${SS_DB_PASSWORD} ${SS_DATABASE} -e 'SHOW TABLES;' | [ $(wc -l) -gt 885 ]
51+
interval: 60s
52+
timeout: 10s
53+
retries: 60
54+
start_period: 60s
55+
volumes:
56+
- ./docker-compose/mysql/model:/docker-entrypoint-initdb.d
57+
- /tmp/mysql/www-openstack/model:/var/lib/mysql
58+
networks:
59+
- www-openstack-local-net
60+
env_file: ./.env
61+
nginx:
62+
image: nginx:alpine
63+
container_name: nginx-www-openstack
64+
restart: unless-stopped
65+
ports:
66+
- "9000:80"
67+
volumes:
68+
- ./:/var/www
69+
- ./docker-compose/nginx:/etc/nginx/conf.d/
70+
networks:
71+
- www-openstack-local-net
72+
env_file: ./.env
73+
depends_on:
74+
- app
75+
networks:
76+
www-openstack-local-net:
77+
driver: bridge

docker-compose/mysql/model/.gitkeep

Whitespace-only changes.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
server {
2+
listen 80; ## listen for ipv4
3+
listen [::]:80; ## listen for ipv6
4+
5+
error_log /var/log/nginx/error.log;
6+
access_log /var/log/nginx/access.log;
7+
root /var/www;
8+
9+
location / {
10+
try_files $uri /framework/main.php?url=$uri&$query_string;
11+
}
12+
location ^~ /.well-known/ {
13+
try_files $uri /framework/main.php?url=$uri&$query_string;
14+
}
15+
location ^~ /assets/ {
16+
sendfile on;
17+
try_files $uri =404;
18+
}
19+
location ~ /framework/.*(main|rpc|tiny_mce_gzip)\.php$ {
20+
fastcgi_buffer_size 32k;
21+
fastcgi_busy_buffers_size 64k;
22+
fastcgi_buffers 4 32k;
23+
fastcgi_keep_conn on;
24+
fastcgi_read_timeout 300;
25+
fastcgi_pass app:9000;
26+
fastcgi_index index.php;
27+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
28+
include fastcgi_params;
29+
}
30+
31+
location ~ /(openstack|framework|cms)/.*\.(php|php3|php4|php5|phtml|inc)$ {
32+
deny all;
33+
}
34+
location ~ /\.. {
35+
deny all;
36+
}
37+
location ~ \.ss$ {
38+
satisfy any;
39+
allow 127.0.0.1;
40+
deny all;
41+
}
42+
location ~ web\.config$ {
43+
deny all;
44+
}
45+
location ~ \.ya?ml$ {
46+
deny all;
47+
}
48+
location ^~ /vendor/ {
49+
deny all;
50+
}
51+
location ~* /silverstripe-cache/ {
52+
deny all;
53+
}
54+
location ~* composer\.(json|lock)$ {
55+
deny all;
56+
}
57+
location ~* /(cms|framework)/silverstripe_version$ {
58+
deny all;
59+
}
60+
location ~* \.(png|jpg|jpeg|gif|ico)$ {
61+
expires 1y;
62+
log_not_found off;
63+
}
64+
location ~* \.(js)$ {
65+
expires 24h;
66+
log_not_found off;
67+
}
68+
location ~* \.(css)$ {
69+
expires 24h;
70+
log_not_found off;
71+
}
72+
location ~ \.ini {
73+
deny all;
74+
}
75+
location ~ \.pickle$ {
76+
deny all;
77+
}
78+
location ~ \.py$ {
79+
deny all;
80+
}
81+
location ~ \.sh$ {
82+
deny all;
83+
}
84+
location ~ \.mo$ {
85+
deny all;
86+
}
87+
location ~ \.po$ {
88+
deny all;
89+
}
90+
location ^~ /env/ {
91+
deny all;
92+
}
93+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[xdebug]
2+
zend_extension=xdebug.so
3+
xdebug.log="/var/www/xdebug.log"
4+
xdebug.mode=debug
5+
xdebug.client_host=host.docker.internal
6+
xdebug.start_with_request=yes
7+
xdebug.idekey=PHPSTORM

0 commit comments

Comments
 (0)