-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
360 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,70 @@ | ||
FROM ubuntu:14.04.5 | ||
|
||
MAINTAINER Sebastian Marcet <smarcet@gmail.com> | ||
|
||
ENV container docker | ||
ENV DEFAULT_LOCALE en_US | ||
# let the container know that there is no tty | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
#Optional, update mirrors speedups updates, but some mirrors sometimes fail | ||
#RUN sed -i -e 's,http://[^ ]*,mirror://mirrors.ubuntu.com/mirrors.txt,' /etc/apt/sources.list | ||
|
||
#update apt sources | ||
RUN apt-get update --fix-missing | ||
|
||
#install required packages | ||
RUN apt-get --no-install-recommends install -y apt-utils openssh-server sudo curl wget nfs-common puppet puppet-common && \ | ||
apt-get clean #cleanup to reduce image size | ||
|
||
# Create and configure vagrant user | ||
RUN useradd --create-home -s /bin/bash vagrant | ||
WORKDIR /home/vagrant | ||
# fix --force-yes issue on apt-get install | ||
RUN echo 'APT::Get::Assume-Yes "true"; \n\ | ||
APT::Get::force-yes "true";' > /etc/apt/apt.conf.d/99forceyesconf | ||
# Configure SSH access | ||
RUN mkdir -p /home/vagrant/.ssh && \ | ||
echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" > /home/vagrant/.ssh/authorized_keys && \ | ||
chown -R vagrant: /home/vagrant/.ssh && \ | ||
adduser vagrant sudo && \ | ||
`# Enable passwordless sudo for users under the "sudo" group` && \ | ||
sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers && \ | ||
echo -n 'vagrant:vagrant' | chpasswd && \ | ||
`# Thanks to http://docs.docker.io/en/latest/examples/running_ssh_service/` && \ | ||
mkdir /var/run/sshd | ||
|
||
# Expose ports | ||
EXPOSE 80 | ||
#leave the SHH daemon (and container) running | ||
CMD /usr/sbin/sshd -D | ||
FROM php:7.2-fpm | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
ARG NVM_VERSION="v0.39.7" | ||
ARG GITHUB_OAUTH_TOKEN | ||
ARG XDEBUG_VERSION="xdebug-3.1.6" | ||
|
||
ENV NVM_VERSION=$NVM_VERSION | ||
ENV NODE_VERSION="12.22.12" | ||
ENV NVM_DIR=/root/.nvm | ||
ENV COMPOSER_ALLOW_SUPERUSER=1 | ||
ENV GITHUB_OAUTH_TOKEN=$GITHUB_OAUTH_TOKEN | ||
ENV PHP_DIR /usr/local/etc/php | ||
|
||
# base packages | ||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
curl \ | ||
libpng-dev \ | ||
libonig-dev \ | ||
libxml2-dev \ | ||
zip \ | ||
unzip \ | ||
redis-tools \ | ||
nano \ | ||
python3 \ | ||
make \ | ||
g++\ | ||
gpg \ | ||
gettext \ | ||
libgmp-dev | ||
|
||
RUN apt clean && rm -rf /var/lib/apt/lists/* | ||
|
||
RUN docker-php-ext-install mbstring exif pcntl bcmath sockets gettext gmp gd mysqli | ||
RUN docker-php-ext-enable gd mysqli | ||
# XDEBUG | ||
RUN yes | pecl install ${XDEBUG_VERSION} | ||
COPY docker-compose/php/docker-php-ext-xdebug.ini $PHP_DIR/conf.d/docker-php-ext-xdebug.ini | ||
|
||
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" | ||
RUN echo 'memory_limit = 512M' >> $PHP_INI_DIR/php.ini; | ||
|
||
# nvm | ||
|
||
RUN mkdir $NVM_DIR \ | ||
&& curl https://raw.githubusercontent.com/creationix/nvm/$NVM_VERSION/install.sh | bash \ | ||
&& . $NVM_DIR/nvm.sh \ | ||
&& nvm install $NODE_VERSION \ | ||
&& nvm alias default $NODE_VERSION \ | ||
&& nvm use default | ||
|
||
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules | ||
ENV PATH $NVM_DIR/v$NODE_VERSION/bin:$PATH | ||
|
||
# yarn | ||
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - | ||
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list | ||
RUN apt update && apt install -y yarn | ||
|
||
# install node | ||
RUN curl -fsSL https://deb.nodesource.com/setup_12.x | bash - | ||
RUN apt-get install -y nodejs | ||
|
||
WORKDIR /var/www | ||
COPY . /var/www | ||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | ||
|
||
RUN composer config -g github-oauth.github.com $GITHUB_OAUTH_TOKEN | ||
RUN git config --global --add safe.directory /var/www |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
Run Local Dev Server | ||
==================== | ||
|
||
1. Create [.env](.env) file with following properties | ||
```dotenv | ||
GITHUB_OAUTH_TOKEN="<GITHUB TOKEN FROM YOUR GITHUB ACCOUNT>" | ||
SS_DB_HOST=db_model | ||
SS_DATABASE=model | ||
SS_DB_USERNAME=root | ||
SS_DB_PASSWORD=1qaz2wsx | ||
REDIS_HOST=redis | ||
REDIS_PORT=6379 | ||
REDIS_DB=0 | ||
REDIS_PASSWORD=1qaz2wsx! | ||
REDIS_DATABASES=16 | ||
``` | ||
2. Create a [_ss_environment.php](_ss_environment.php) file with follwing properties | ||
```php | ||
<?php | ||
/* What kind of environment is this: development, test, or live (ie, production)? */ | ||
define('SS_ENVIRONMENT_TYPE', 'dev'); | ||
|
||
/* Database connection */ | ||
define('SS_DATABASE_SERVER', 'db_model'); | ||
define('SS_DATABASE_USERNAME', 'root'); | ||
define('SS_DATABASE_PASSWORD', '1qaz2wsx'); | ||
define('SS_DATABASE_CLASS','CustomMySQLDatabase'); | ||
/* Global variables */ | ||
$database = 'model'; | ||
$email_from = '<YOUR EMAIL>'; | ||
$email_log = '<YOUR EMAIL>'; | ||
define('SMTPMAILER_SMTP_SERVER_ADDRESS', 'smtp.sendgrid.net'); # SMTP server address | ||
define('SMTPMAILER_DO_AUTHENTICATE', true); # Turn on SMTP server authentication. Set to false for an anonymous connection | ||
define('SMTPMAILER_USERNAME', ''); # SMTP server username, if SMTPAUTH == true | ||
define('SMTPMAILER_PASSWORD', ''); # SMTP server password, if SMTPAUTH == true | ||
define('SENDGRID_API_KEY', '<SENDGRID API KEY>'); | ||
``` | ||
3. Drop here [docker-compose/mysql/model](docker-compose/mysql/model) the database dump *.sql file | ||
4. Install docker and docker compose see | ||
[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) | ||
5. Run script ./start_local_server.sh | ||
|
||
Useful Commands | ||
=============== | ||
|
||
check containers health status | ||
|
||
````bash | ||
docker inspect --format "{{json .State.Health }}" www-openstack-model-db-local | jq '. | ||
```` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Debug config at PHPSTORM | ||
========================== | ||
|
||
1. Add a new CLI interpreter using [Docker] | ||
1. choose image www-openstack:latest | ||
2. click [OK] | ||
3. select new CLI interpreter | ||
4. click [Apply] | ||
|
||
2. Edit network settings at container | ||
1. goto Settings->PHP and locate "Docker Container" input. | ||
2. Click on Folder icon. | ||
3. a new popup titled "Edit Docker Container Settings" will open. | ||
4. fill the "Network Mode" input with the bridge name, to find it out run ```$docker network list``` command. | ||
and put the name of the bridge there. | ||
|
||
3. Create new server | ||
1. goto Settings->PHP->Servers | ||
2. click on [+] | ||
3. fill up Name with "Docker" | ||
4. fill up Host with "0.0.0.0" | ||
5. fill up Port with "80" | ||
6. click use map mappings | ||
7. map root to /var/www | ||
|
||
4. Create a remote debug configuration profile | ||
1. goto Run->Debug->Edit Configurations | ||
2. create a new "PHP Remote debug" Profile | ||
3. set name as "Docker" | ||
4. check "Filter debug connection by IDE key" | ||
5. set IDE KEY as "PHPSTORM" | ||
6. set Server as "Docker" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
set -e | ||
export DOCKER_SCAN_SUGGEST=false | ||
|
||
docker compose down | ||
docker compose build --no-cache | ||
docker compose up -d --build --force-recreate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
services: | ||
app: | ||
build: | ||
context: ./ | ||
dockerfile: Dockerfile | ||
args: | ||
GITHUB_OAUTH_TOKEN: ${GITHUB_OAUTH_TOKEN} | ||
extra_hosts: | ||
- "host.docker.internal:host-gateway" | ||
image: www-openstack | ||
container_name: www-openstack | ||
restart: unless-stopped | ||
working_dir: /var/www/ | ||
volumes: | ||
- ./:/var/www | ||
networks: | ||
- www-openstack-local-net | ||
depends_on: | ||
redis: | ||
condition: service_started | ||
db_model: | ||
condition: service_healthy | ||
redis: | ||
image: redis:latest | ||
container_name: redis-www-openstack | ||
restart: always | ||
command: redis-server --save 20 1 --loglevel warning --requirepass ${REDIS_PASSWORD} | ||
ports: | ||
- ${REDIS_PORT} | ||
volumes: | ||
- /tmp/www-openstack/redis:/root/redis | ||
- ./docker-compose/redis/redis.conf:/usr/local/etc/redis/redis.conf | ||
networks: | ||
- www-openstack-local-net | ||
env_file: ./.env | ||
db_model: | ||
image: mysql:8.0 | ||
container_name: www-openstack-model-db-local | ||
command: --default-authentication-plugin=mysql_native_password --sql_mode=NO_ENGINE_SUBSTITUTION | ||
restart: unless-stopped | ||
ports: | ||
- "32010:3306" | ||
environment: | ||
MYSQL_DATABASE: ${SS_DATABASE} | ||
MYSQL_PASSWORD: ${SS_DB_PASSWORD} | ||
MYSQL_ROOT_PASSWORD: ${SS_DB_PASSWORD} | ||
SERVICE_TAGS: dev | ||
SERVICE_NAME: mysql | ||
healthcheck: | ||
test: mysql -u ${SS_DB_USERNAME} --password=${SS_DB_PASSWORD} ${SS_DATABASE} -e 'SHOW TABLES;' | [ $(wc -l) -gt 885 ] | ||
interval: 60s | ||
timeout: 10s | ||
retries: 60 | ||
start_period: 60s | ||
volumes: | ||
- ./docker-compose/mysql/model:/docker-entrypoint-initdb.d | ||
- /tmp/mysql/www-openstack/model:/var/lib/mysql | ||
networks: | ||
- www-openstack-local-net | ||
env_file: ./.env | ||
nginx: | ||
image: nginx:alpine | ||
container_name: nginx-www-openstack | ||
restart: unless-stopped | ||
ports: | ||
- "9000:80" | ||
volumes: | ||
- ./:/var/www | ||
- ./docker-compose/nginx:/etc/nginx/conf.d/ | ||
networks: | ||
- www-openstack-local-net | ||
env_file: ./.env | ||
depends_on: | ||
- app | ||
networks: | ||
www-openstack-local-net: | ||
driver: bridge |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
server { | ||
listen 80; ## listen for ipv4 | ||
listen [::]:80; ## listen for ipv6 | ||
|
||
error_log /var/log/nginx/error.log; | ||
access_log /var/log/nginx/access.log; | ||
root /var/www; | ||
|
||
location / { | ||
try_files $uri /framework/main.php?url=$uri&$query_string; | ||
} | ||
location ^~ /.well-known/ { | ||
try_files $uri /framework/main.php?url=$uri&$query_string; | ||
} | ||
location ^~ /assets/ { | ||
sendfile on; | ||
try_files $uri =404; | ||
} | ||
location ~ /framework/.*(main|rpc|tiny_mce_gzip)\.php$ { | ||
fastcgi_buffer_size 32k; | ||
fastcgi_busy_buffers_size 64k; | ||
fastcgi_buffers 4 32k; | ||
fastcgi_keep_conn on; | ||
fastcgi_read_timeout 300; | ||
fastcgi_pass app:9000; | ||
fastcgi_index index.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
include fastcgi_params; | ||
} | ||
|
||
location ~ /(openstack|framework|cms)/.*\.(php|php3|php4|php5|phtml|inc)$ { | ||
deny all; | ||
} | ||
location ~ /\.. { | ||
deny all; | ||
} | ||
location ~ \.ss$ { | ||
satisfy any; | ||
allow 127.0.0.1; | ||
deny all; | ||
} | ||
location ~ web\.config$ { | ||
deny all; | ||
} | ||
location ~ \.ya?ml$ { | ||
deny all; | ||
} | ||
location ^~ /vendor/ { | ||
deny all; | ||
} | ||
location ~* /silverstripe-cache/ { | ||
deny all; | ||
} | ||
location ~* composer\.(json|lock)$ { | ||
deny all; | ||
} | ||
location ~* /(cms|framework)/silverstripe_version$ { | ||
deny all; | ||
} | ||
location ~* \.(png|jpg|jpeg|gif|ico)$ { | ||
expires 1y; | ||
log_not_found off; | ||
} | ||
location ~* \.(js)$ { | ||
expires 24h; | ||
log_not_found off; | ||
} | ||
location ~* \.(css)$ { | ||
expires 24h; | ||
log_not_found off; | ||
} | ||
location ~ \.ini { | ||
deny all; | ||
} | ||
location ~ \.pickle$ { | ||
deny all; | ||
} | ||
location ~ \.py$ { | ||
deny all; | ||
} | ||
location ~ \.sh$ { | ||
deny all; | ||
} | ||
location ~ \.mo$ { | ||
deny all; | ||
} | ||
location ~ \.po$ { | ||
deny all; | ||
} | ||
location ^~ /env/ { | ||
deny all; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[xdebug] | ||
zend_extension=xdebug.so | ||
xdebug.log="/var/www/xdebug.log" | ||
xdebug.mode=debug | ||
xdebug.client_host=host.docker.internal | ||
xdebug.start_with_request=yes | ||
xdebug.idekey=PHPSTORM |
Oops, something went wrong.