Subject | Hash | Author | Date (UTC) |
---|---|---|---|
Initial commit | f0ac3b6d6f330c3ed2e5c760a30abf15601d0494 | Ivaylo Iliev | 2017-08-26 22:23:30 |
File | Lines added | Lines deleted |
---|---|---|
.gitignore | 2 | 0 |
README.md | 24 | 0 |
build | 35 | 0 |
docker/application/Dockerfile | 56 | 0 |
docker/application/etc/nginx/sites-enabled/default | 19 | 0 |
src/.keepme | 0 | 0 |
File .gitignore added (mode: 100644) (index 0000000..b8372e6) | |||
1 | # Emacs | ||
2 | *~ |
File README.md added (mode: 100644) (index 0000000..97b1830) | |||
1 | # nasa test application | ||
2 | |||
3 | Nasa test application | ||
4 | |||
5 | ## Build docker | ||
6 | |||
7 | ### On GNU/Linux and Mac | ||
8 | |||
9 | use ./build script from root folder | ||
10 | |||
11 | ### On Windows | ||
12 | |||
13 | build images from the docker folder and map the source of the application to the src from root folder | ||
14 | |||
15 | ## Run on local | ||
16 | |||
17 | ### On GNU/Linux and Mac | ||
18 | |||
19 | - if you use the ./build script open localhost:8080 | ||
20 | - if you build in another way follow the port forwarding | ||
21 | |||
22 | ### On Windows | ||
23 | |||
24 | - follow the port forwarding after image is run |
File build added (mode: 100755) (index 0000000..e865b8f) | |||
1 | if [ -n "$1" ]; then | ||
2 | VERSION=$1 | ||
3 | else | ||
4 | printf "Version shall be set as a parameter.\nExample:\n\tbuild YOUR_VERSION\n\n" | ||
5 | |||
6 | read -p "Do you want to build image with version 0.0.1 y/N? " -n 1 -r | ||
7 | echo # (optional) move to a new line | ||
8 | if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
9 | echo # (optional) move to a new line | ||
10 | ./build 0.0.1 | ||
11 | else | ||
12 | echo "exiting" | ||
13 | fi | ||
14 | |||
15 | exit -1 | ||
16 | fi | ||
17 | |||
18 | docker build -f docker/application/Dockerfile -t app/server:$VERSION docker/application/ | ||
19 | |||
20 | printf "\nShow all app/server images below \n\n" | ||
21 | |||
22 | printf "REPOSITORY TAG IMAGE ID CREATED SIZE\n\n" | ||
23 | docker images | grep app/server | ||
24 | |||
25 | printf "\n\n" | ||
26 | |||
27 | read -p "Do you want to run image with version $VERSION y/N? " -n 1 -r | ||
28 | echo # (optional) move to a new line | ||
29 | if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
30 | echo # (optional) move to a new line | ||
31 | docker run --name dev-server -p 8080:80 -v $(pwd)/src:/var/www/html -d app/server:$VERSION | ||
32 | docker exec -it dev-server bash | ||
33 | else | ||
34 | printf "\n\nWhat is next:\n\tdocker run --name dev-server -p 8080:80 -v $(pwd)/src:/var/www/html -d app/server:$VERSION\n\tdocker exec -it dev-server bash" | ||
35 | fi |
File docker/application/Dockerfile added (mode: 100644) (index 0000000..8881193) | |||
1 | # Install php and nginx | ||
2 | |||
3 | FROM debian:jessie | ||
4 | MAINTAINER Ivaylo Iliev <ranapat@yahoo.com> | ||
5 | |||
6 | # Install base packages | ||
7 | RUN \ | ||
8 | apt-get update > /dev/null 2>&1 && \ | ||
9 | apt-get install -y curl wget apt-transport-https lsb-release ca-certificates zip unzip > /dev/null 2>&1 | ||
10 | |||
11 | # Install php7.1 | ||
12 | RUN \ | ||
13 | wget -nv -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg > /dev/null 2>&1 && \ | ||
14 | echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list && \ | ||
15 | apt-get update > /dev/null 2>&1 && \ | ||
16 | apt-get install -y php7.1-fpm php7.1 php7.1-xml php7.1-intl php7.1-mysql php7.1-bz2 php7.1-zip > /dev/null 2>&1 && \ | ||
17 | echo "cgi.fix_pathinfo=0" >> /etc/php/7.1/fpm/php.ini | ||
18 | |||
19 | # Install Nginx. | ||
20 | RUN \ | ||
21 | apt-get install -y nginx > /dev/null 2>&1 && \ | ||
22 | echo "\ndaemon off;" >> /etc/nginx/nginx.conf && \ | ||
23 | chown -R www-data:www-data /var/lib/nginx | ||
24 | |||
25 | COPY etc/nginx/sites-enabled/default /etc/nginx/sites-enabled/default | ||
26 | |||
27 | # Install Composer | ||
28 | RUN \ | ||
29 | php -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');" && \ | ||
30 | php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer && \ | ||
31 | rm /tmp/composer-setup.php | ||
32 | |||
33 | # Install Symfony | ||
34 | RUN \ | ||
35 | mkdir -p /usr/local/bin && \ | ||
36 | curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony && \ | ||
37 | chmod a+x /usr/local/bin/symfony | ||
38 | |||
39 | # Define mountable directories. | ||
40 | VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx"] | ||
41 | |||
42 | RUN \ | ||
43 | rm /var/www/html/* | ||
44 | |||
45 | # Define working directory. | ||
46 | WORKDIR /var/www/html | ||
47 | |||
48 | # Define default command. | ||
49 | CMD \ | ||
50 | /etc/init.d/nginx start & \ | ||
51 | /etc/init.d/php7.1-fpm start & \ | ||
52 | tail -f /var/log/dmesg | ||
53 | |||
54 | # Expose ports. | ||
55 | EXPOSE 80 | ||
56 | EXPOSE 443 |
File docker/application/etc/nginx/sites-enabled/default added (mode: 100644) (index 0000000..94aa242) | |||
1 | server { | ||
2 | listen 80 default_server; | ||
3 | listen [::]:80 default_server; | ||
4 | |||
5 | root /var/www/html; | ||
6 | |||
7 | index index.php index.html index.htm; | ||
8 | |||
9 | server_name _; | ||
10 | |||
11 | location / { | ||
12 | try_files $uri $uri/ =404; | ||
13 | } | ||
14 | |||
15 | location ~ \.php$ { | ||
16 | include snippets/fastcgi-php.conf; | ||
17 | fastcgi_pass unix:/run/php/php7.1-fpm.sock; | ||
18 | } | ||
19 | } |
File src/.keepme added (mode: 100644) (index 0000000..e69de29) |