-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from uzulla/make-distribution
配布用ZIPファイル生成スクリプト
- Loading branch information
Showing
8 changed files
with
209 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fc2blog_dist_* | ||
fc2blog/ | ||
test_vm/fc2.zip |
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,19 @@ | ||
.PHONY: | ||
build: | ||
make clean | ||
git clone --depth=1 --branch=main https://github.com/uzulla/fc2blog.git fc2blog | ||
rm -rf fc2blog/.git | ||
cd fc2blog && php ../../composer.phar install --no-dev --optimize-autoloader | ||
cd fc2blog && zip -r ../fc2blog_dist_`git rev-parse --short HEAD`.zip app public | ||
|
||
.PHONY: | ||
clean: | ||
-rm -rf fc2blog | ||
-rm fc2blog_dist_* | ||
-rm test_vm/fc2.zip | ||
|
||
.PHONY: | ||
test: | ||
make build | ||
cp fc2blog_dist_`git -C fc2blog rev-parse --short HEAD`.zip test_vm/fc2.zip | ||
cd test_vm && make image-no-cache && make bash |
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,42 @@ | ||
# Create distribution zip | ||
|
||
Create a ZIP file for distribute. | ||
|
||
## IMPORTANT NOTICE | ||
|
||
The script will be make a zip that cloned from `https://github.com/uzulla/fc2blog` (not `fc2blog/blog`). | ||
|
||
This situation is temporary on the development. will be change to `fc2blog/blog`. | ||
|
||
## build zip | ||
|
||
``` | ||
$ make build | ||
$ ls fc2blog_dist_* | ||
fc2blog_dist_*****.zip | ||
``` | ||
|
||
`fc2blog_dist_*****.zip` is distributable zip. (***** is short commit id) | ||
|
||
that contain `app`, `public`, and `app/vendor/`(libraries that installed by the composer). | ||
|
||
## test on Ubuntu vm(docker) | ||
|
||
``` | ||
$ make test | ||
{some logs output} | ||
If you want exit. please exit or ctrl-D | ||
================================== | ||
http://172.17.0.2/admin/common/install | ||
================================== | ||
{some logs output} | ||
root@2792c09097ef:/# exit | ||
``` | ||
|
||
> All data is not permanent. All data will be lost when exited. | ||
## clean | ||
|
||
``` | ||
$ make clean | ||
``` |
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,28 @@ | ||
# for development purpose. | ||
<VirtualHost *:80> | ||
DocumentRoot /var/www/html | ||
ErrorLog /dev/stdout | ||
CustomLog /dev/stdout combined | ||
|
||
<Directory /var/www/html> | ||
Options FollowSymlinks Includes | ||
AllowOverride All | ||
Require all granted | ||
</Directory> | ||
</VirtualHost> | ||
|
||
<VirtualHost _default_:443> | ||
DocumentRoot /var/www/html | ||
ErrorLog /dev/stdout | ||
CustomLog /dev/stdout combined | ||
|
||
SSLEngine on | ||
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem | ||
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key | ||
|
||
<Directory /var/www/html> | ||
Options FollowSymlinks Includes | ||
AllowOverride All | ||
Require all granted | ||
</Directory> | ||
</VirtualHost> |
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,56 @@ | ||
FROM ubuntu:focal | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN set -eux \ | ||
&& apt-get update -y \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get install -y software-properties-common iproute2 vim git wget unzip locales ssl-cert \ | ||
&& sed -i -E 's/# (ja_JP.UTF-8)/\1/' /etc/locale.gen \ | ||
&& locale-gen \ | ||
&& rm -rf /tmp/* | ||
|
||
RUN add-apt-repository -y ppa:ondrej/php \ | ||
&& add-apt-repository -y ppa:ondrej/apache2 \ | ||
&& apt-get update \ | ||
&& apt-get install -y apache2 mysql-server php8.0 libapache2-mod-php8.0 php8.0-intl php8.0-mbstring php8.0-gd php8.0-mysql | ||
|
||
ARG PUID=1000 | ||
ARG PGID=1000 | ||
|
||
RUN groupmod -o -g $PGID www-data && \ | ||
usermod -o -u $PUID -g www-data www-data && \ | ||
usermod --shell /bin/bash www-data | ||
|
||
COPY 001-blog.conf /etc/apache2/sites-available/ | ||
|
||
RUN make-ssl-cert generate-default-snakeoil --force-overwrite \ | ||
&& a2enmod rewrite \ | ||
&& a2enmod ssl \ | ||
&& a2ensite 001-blog \ | ||
&& a2dissite 000-default.conf \ | ||
&& a2dissite default-ssl.conf | ||
|
||
RUN mkdir /var/run/mysqld \ | ||
&& chmod 777 /var/run/mysqld | ||
|
||
# XXX | ||
RUN sh -c "/usr/bin/mysqld_safe --user=mysql &" \ | ||
&& sleep 3 \ | ||
&& mysql_secure_installation -ppass -D \ | ||
&& echo "CREATE DATABASE fc2" | mysql \ | ||
&& echo "CREATE USER 'dbuser'@'127.0.0.1' IDENTIFIED BY 'd1B2p3a#s!s';" | mysql \ | ||
&& echo "GRANT ALL ON fc2.* TO 'dbuser'@'127.0.0.1';" | mysql | ||
|
||
COPY fc2.zip /tmp | ||
RUN cd tmp \ | ||
&& unzip fc2.zip \ | ||
&& mv app /var/www/ \ | ||
&& mv public/* /var/www/html/ \ | ||
&& mv public/.htaccess /var/www/html/ \ | ||
&& chown -R www-data:www-data /var/www/ \ | ||
&& rm /var/www/html/index.html | ||
|
||
COPY config.php /var/www/app/ | ||
|
||
COPY startup.sh / |
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,22 @@ | ||
PHONY: | ||
image: | ||
# alignment local UID/GID and docker UID/GID for Linux dev env. | ||
$(eval UID := $(shell id -u)) | ||
$(eval GID := $(shell id -g)) | ||
docker build -t fc2_dist_test_vm --build-arg PUID=$(UID) --build-arg PGID=$(GID) . | ||
|
||
PHONY: | ||
image-no-cache: | ||
# alignment local UID/GID and docker UID/GID for Linux dev env. | ||
$(eval UID := $(shell id -u)) | ||
$(eval GID := $(shell id -g)) | ||
docker build -t fc2_dist_test_vm --no-cache --build-arg PUID=$(UID) --build-arg PGID=$(GID) . | ||
|
||
PHONY: | ||
run: | ||
docker run --rm -it fc2_dist_test_vm sh -c "/startup.sh ; bash" | ||
|
||
PHONY: | ||
bash: | ||
docker run --rm -it fc2_dist_test_vm bash | ||
|
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,20 @@ | ||
<?php | ||
error_reporting(-1); | ||
|
||
// DBの接続情報 | ||
define('DB_HOST', '127.0.0.1'); // dbのホスト名 | ||
define('DB_USER', 'dbuser'); // dbのユーザー名 | ||
define('DB_PASSWORD', 'd1B2p3a#s!s'); // dbのパスワード | ||
define('DB_DATABASE', 'fc2'); // dbのデータベース名 | ||
define('DB_CHARSET', 'UTF8MB4'); // MySQL 5.5未満の場合はUTF8を指定してください | ||
|
||
// サーバーの設定情報 | ||
define('DOMAIN', 'example.test'); // ドメイン名 | ||
define('HTTP_PORT', '80'); // HTTP時ポート | ||
define('HTTPS_PORT', '443'); // HTTPS時ポート | ||
|
||
define('PASSWORD_SALT', 'BgbXeZJQy9ijBNThVZ0zU6wbiXmerjpJ'); | ||
|
||
define('WWW_DIR', __DIR__ . '/../html/'); | ||
|
||
require(__DIR__ . '/core/bootstrap.php'); |
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,19 @@ | ||
#!/usr/bin/env sh | ||
|
||
/usr/bin/mysqld_safe --user=mysql & | ||
|
||
APACHE_RUN_DIR=/var/run/apache2 \ | ||
APACHE_PID_FILE=/var/run/apache2/pid \ | ||
APACHE_RUN_USER=www-data \ | ||
APACHE_RUN_GROUP=www-data \ | ||
APACHE_LOG_DIR=/var/log/apache2/ \ | ||
APACHE_CONFDIR=/etc/apache2 \ | ||
/usr/sbin/apache2 -DFOREGROUND & | ||
|
||
sleep 3 | ||
echo "If you want exit. please exit or ctrl-D" | ||
|
||
echo ================================== | ||
echo "http://`ip -4 addr | grep -oP '(?<=inet\s)\d+(\.\d+){3}' |grep -v 127.0.0.1`/admin/common/install" | ||
echo ================================== | ||
|