Skip to content
This repository was archived by the owner on Apr 1, 2021. It is now read-only.

Commit 9965f86

Browse files
committed
create dockerfile
1 parent d72c8ab commit 9965f86

File tree

5 files changed

+97
-0
lines changed

5 files changed

+97
-0
lines changed

.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/node_modules
2+
/public/hot
3+
/storage/*.key
4+
/vendor
5+
/.idea
6+
/.vscode
7+
/.vagrant
8+
Homestead.json
9+
Homestead.yaml
10+
npm-debug.log
11+
yarn-error.log
12+
.DS_Store

Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM node:8 as compiler
2+
WORKDIR /var/www
3+
COPY package.json /var/www
4+
COPY package-lock.json /var/www
5+
RUN npm ci
6+
7+
COPY . /var/www
8+
RUN npm run prod
9+
RUN rm -rf /var/www/node_modules/
10+
11+
FROM php:7.2-fpm as server
12+
RUN set -x \
13+
&& apt-get update -y \
14+
&& apt-get install --no-install-recommends --no-install-suggests -y \
15+
nginx nginx-extras libcurl3-dev curl git zip unzip zlib1g-dev
16+
RUN docker-php-ext-install zip
17+
18+
WORKDIR /var/www
19+
20+
ENV TZ=Asia/Jakarta
21+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
22+
23+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
24+
COPY composer.json composer.json
25+
COPY composer.lock composer.lock
26+
RUN composer config -g repos.packagist composer https://packagist.phpindonesia.id
27+
RUN composer install --prefer-dist --no-scripts --no-dev --no-autoloader && rm -rf /root/.composer
28+
29+
COPY deploy/site.conf /etc/nginx/sites-available/default
30+
COPY deploy/php.ini /usr/local/etc/php/
31+
COPY --from=compiler /var/www /var/www
32+
33+
RUN composer dump-autoload --no-scripts --no-dev --optimize
34+
RUN chown -R www-data:www-data /var/www
35+
RUN rm -rf /var/www/html/ /var/www/deploy/ /var/www/Dockerfile
36+
37+
EXPOSE 80
38+
CMD service nginx start && php-fpm && tail -f /var/log/nginx/error.log

deploy/php.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
date.timezone = Asia/Jakarta
2+
upload_max_filesize = 100M
3+
post_max_size = 100M

deploy/site.conf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
server {
2+
set $root_path '/var/www/public';
3+
4+
error_log /var/log/nginx/error.log;
5+
access_log /var/log/nginx/access.log;
6+
7+
root $root_path;
8+
index index.php;
9+
10+
location / {
11+
try_files $uri $uri/ /index.php?$args;
12+
}
13+
14+
client_max_body_size 100m;
15+
16+
location ~ \.php {
17+
include fastcgi_params;
18+
19+
fastcgi_index /index.php;
20+
fastcgi_pass 127.0.0.1:9000;
21+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
22+
fastcgi_param PATH_INFO $fastcgi_path_info;
23+
fastcgi_intercept_errors on;
24+
fastcgi_param SCRIPT_FILENAME $root_path$fastcgi_script_name;
25+
}
26+
27+
location ~ /\.git {
28+
deny all;
29+
}
30+
}

docker.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
port=${1:-8888}
4+
name="${PWD##*/}"
5+
image="$name-image"
6+
container="$name-container"
7+
8+
docker build -t $image .
9+
docker rm -f $container
10+
docker run -itd --restart unless-stopped --name $container --publish 8888:80 $image
11+
12+
echo "|------------------------------------------------------------"
13+
echo "| Success running on port $port, check http://localhost:$port"
14+
echo "|------------------------------------------------------------"

0 commit comments

Comments
 (0)