Skip to content

Commit b9c6380

Browse files
authored
Merge pull request #18 from movabletype/release-2.0
Release 2.0
2 parents dc12ad2 + 752cf14 commit b9c6380

17 files changed

Lines changed: 1207 additions & 110 deletions

File tree

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [2.0.0] - 2022-02-21
10+
11+
### Added
12+
13+
#### Customized Docker containers
14+
15+
You can launch the container with customizations of your choice.
16+
And the development container configuration for Visual Studio Code is included by default.
17+
18+
```
19+
$ make up-psgi ... DOCKER_MT_DOCKERFILE=Dockerfile.devcontainer REPO="$HOME/src/github.com/username/mt-plugin-AwesomePlugin"
20+
```
21+
22+
#### Support mount flag (especially for Docker for Mac)
23+
24+
Docker for Mac has slow file access on bind mounts, but if you use a dev container, using :delegated may improve the situation.
25+
26+
```
27+
$ make up-psgi ... DOCKER_VOLUME_MOUNT_FLAG=delegated
28+
```
29+
30+
### Changed
31+
32+
* Also skip `git fetch` when "$UPDATE_BRANCH" is "no".
33+
* Rename environment variable DOCKER_COMPOSE_YML_MIDDLEWARES to DOCKER_COMPOSE_YAML_MIDDLEWARES
34+
935
## [1.1.1] - 2022-01-03
1036

1137
### Changed

Makefile

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
MAKEFILE_DIR=$(abspath $(dir $(lastword $(MAKEFILE_LIST))))
22

3-
export BASE_SITE_PATH=${MAKEFILE_DIR}/site
4-
export DOCKER=docker
5-
export DOCKER_COMPOSE=docker-compose
6-
export DOCKER_COMPOSE_YML_MIDDLEWARES=-f ./mt/mysql.yml -f ./mt/memcached.yml
7-
export UP_ARGS=-d
8-
export MT_HOME_PATH=${MAKEFILE_DIR}/../movabletype
9-
export UPDATE_BRANCH=yes
3+
export BASE_SITE_PATH:=${MAKEFILE_DIR}/site
4+
export DOCKER:=docker
5+
export DOCKER_COMPOSE:=${shell ${DOCKER} compose >/dev/null 2>&1 && echo 'docker compose' || echo 'docker-compose'}
6+
export DOCKER_COMPOSE_YAML_MIDDLEWARES:=-f ./mt/mysql.yml -f ./mt/memcached.yml
7+
export UP_ARGS:=-d
8+
export MT_HOME_PATH:=${MAKEFILE_DIR}/../movabletype
9+
export UPDATE_BRANCH:=yes
1010

1111
MT_CONFIG_CGI=${shell [ -e mt-config.cgi ] && echo mt-config.cgi || echo mt-config.cgi-original}
1212
BASE_ARCHIVE_PATH=${MAKEFILE_DIR}/archive
@@ -18,17 +18,27 @@ endif
1818
ifneq (${PERL},)
1919
DOCKER_MT_IMAGE=movabletype/test:perl-${PERL}
2020
endif
21+
ifneq (${NODE},)
22+
DOCKER_NODEJS_IMAGE=node:${NODE}
23+
endif
2124
ifneq (${DB},)
2225
DOCKER_MYSQL_IMAGE=${DB}
2326
endif
2427

28+
export DOCKER_COMPOSE_USER_YAML
29+
export DOCKER_MT_BUILD_CONTEXT
30+
export DOCKER_MT_DOCKERFILE
2531
export DOCKER_MT_IMAGE
2632
export DOCKER_MT_SERVICES
33+
export DOCKER_NODEJS_IMAGE
34+
export DOCKER_HTTPD_BUILD_CONTEXT
35+
export DOCKER_HTTPD_DOCKERFILE
2736
export DOCKER_HTTPD_IMAGE
2837
export DOCKER_MYSQL_IMAGE
2938
export DOCKER_MEMCACHED_IMAGE
3039
export DOCKER_LDAP_IMAGE
3140
export DOCKER_FTPD_IMAGE
41+
export DOCKER_VOLUME_MOUNT_FLAG
3242
export MT_RUN_VIA
3343
export HTTPD_EXPOSE_PORT
3444
export PLACKUP
@@ -57,7 +67,7 @@ ifeq ($(wildcard ${MT_CONFIG_CGI_SRC_PATH}),)
5767
$(error You should create ${MT_CONFIG_CGI_SRC_PATH} first.)
5868
endif
5969

60-
_DC=${DOCKER_COMPOSE} -f ./mt/common.yml ${DOCKER_COMPOSE_YML_MIDDLEWARES}
70+
_DC=${DOCKER_COMPOSE} -f ./mt/common.yml ${DOCKER_COMPOSE_YAML_MIDDLEWARES} ${_DC_YAML_OVERRIDE} ${DOCKER_COMPOSE_USER_YAML}
6171

6272

6373
.PHONY: db up down
@@ -126,14 +136,16 @@ ifneq (${PR},)
126136
endif
127137
${MAKE} up-common-invoke-docker-compose MT_HOME_PATH=${MT_HOME_PATH} ${_ARGS} RECIPE="" REPO="" PR="" $(shell [ -n "${DOCKER_MT_IMAGE}" ] && echo "DOCKER_MT_IMAGE=${DOCKER_MT_IMAGE}") $(shell [ -n "${DOCKER_MYSQL_IMAGE}" ] && echo "DOCKER_MYSQL_IMAGE=${DOCKER_MYSQL_IMAGE}")
128138

139+
up-common-invoke-docker-compose: _DC_YAML_OVERRIDE=-f ./mt/${MT_RUN_VIA}.yml ${DOCKER_COMPOSE_YAML_OVERRIDE}
129140
up-common-invoke-docker-compose: setup-mysql-volume
130141
@echo MT_HOME_PATH=${MT_HOME_PATH}
131142
@echo BASE_SITE_PATH=${BASE_SITE_PATH}
132143
@echo DOCKER_MT_IMAGE=${DOCKER_MT_IMAGE}
133144
@echo DOCKER_HTTPD_IMAGE=${DOCKER_HTTPD_IMAGE}
134145
@echo DOCKER_MYSQL_IMAGE=${DOCKER_MYSQL_IMAGE}
135-
${_DC} -f ./mt/${MT_RUN_VIA}.yml ${DOCKER_COMPOSE_YML_OVERRIDE} pull
136-
${_DC} -f ./mt/${MT_RUN_VIA}.yml ${DOCKER_COMPOSE_YML_OVERRIDE} up ${UP_ARGS}
146+
${_DC} pull
147+
${_DC} build
148+
${_DC} up ${UP_ARGS}
137149

138150

139151
ifneq (${REMOVE_VOLUME},)

README.ja.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ $ vagrant mt-dev up ARCHIVE=MT7-R0000.zip
3636
$ vagrant mt-dev exec-mysql SQL='CREATE DATABASE mt /*!40100 DEFAULT CHARACTER SET utf8mb4 */'
3737
```
3838

39-
http://192.168.7.25/cgi-bin/mt/mt.cgi を開くとインストール画面になります。
39+
http://192.168.58.25/cgi-bin/mt/mt.cgi を開くとインストール画面になります。
4040

4141
mt-config.cgiは、mt-dev/mt-config.cgi(またはなければmt-config.cgi-original)が使われます。
4242

bin/git-clone

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ if [ ! -e $dir ]; then
99
git clone $repo $dir
1010
fi
1111

12-
cd $dir
13-
git fetch --all --prune
14-
git fetch --tags --prune
15-
1612
if [ "$UPDATE_BRANCH" = "yes" -o "$UPDATE_BRANCH" = "1" ] && [ -n "$branch" ]; then
13+
cd $dir
14+
git fetch --all --tags --prune
15+
1716
git checkout .
1817
git clean -f
1918

bin/setup-environment

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ use lib "$FindBin::Bin/local/lib/perl5";
99

1010
use Cwd qw(realpath getcwd);
1111
use IO::File;
12+
use JSON::PP qw(encode_json);
1213
use Data::Dumper;
1314
use Digest::MD5;
1415
use Getopt::Long;
1516
use HTTP::Tiny;
1617
use Config::Tiny;
17-
use YAML::Tiny qw(LoadFile DumpFile);
18+
use YAML::Tiny qw(LoadFile Dump);
1819
use File::Basename qw(basename fileparse);
1920
use File::Spec::Functions qw(catfile);
2021
use File::Temp qw(tempfile tmpnam tempdir);
@@ -29,11 +30,15 @@ GetOptions(
2930
my $recipe_dir = realpath("$FindBin::Bin/../recipe");
3031
my $repo_dir = realpath("$FindBin::Bin/../repo");
3132
my $repo_base_dir = realpath("$FindBin::Bin/../..");
32-
my $archive_dir = realpath("$FindBin::Bin/../archive");
33+
my $archive_dir = realpath("$FindBin::Bin/../archive");
3334
my $git_clone_cmd = realpath("$FindBin::Bin/git-clone");
3435

35-
my $env = {};
36-
my $yamls = [];
36+
my $env = {};
37+
my $yamls = [];
38+
my $workspace = {
39+
folders => [],
40+
settings => {},
41+
};
3742

3843
sub handle_recipe {
3944
my $data = shift;
@@ -54,12 +59,12 @@ sub handle_recipe {
5459
for my $k ( keys %$data ) {
5560
my $repo = $data->{$k}{location};
5661
my $dest_dir = $data->{$k}{directory} || do {
57-
( my $dir = $repo ) =~ s{.*/}{};
58-
"$repo_base_dir/$dir";
62+
"$repo_base_dir/@{[basename($repo)]}";
5963
};
6064
if ( $dest_dir !~ m{\A/} ) {
6165
$dest_dir = "$repo_base_dir/$dest_dir";
6266
}
67+
( my $basename = $dest_dir ) =~ s{.*/}{};
6368

6469
if ( $k eq 'core' ) {
6570
$env->{MT_HOME_PATH} = $dest_dir;
@@ -69,18 +74,18 @@ sub handle_recipe {
6974
my $branch = $data->{$k}{branch} || '';
7075

7176
for my $pr ( split /\s+/, $pull_reqs ) {
72-
my ($pr_repo, $pr_id) = ($pr =~ m{([^/]+)/(pull/\d+)});
77+
my ( $pr_repo, $pr_id ) = ( $pr =~ m{([^/]+)/(pull/\d+)} );
7378
next unless $pr_repo && $pr_id;
74-
$branch = $pr_id . '/head' if basename($dest_dir) eq $pr_repo;
79+
$branch = $pr_id . '/head' if $basename eq $pr_repo;
7580
}
7681

7782
{
7883
my %repos = map { $_ => 1 } split /\s+/, $repos;
7984
for my $r ( keys %repos ) {
80-
my ($bn, $br) = $r =~ m{([^/]+)#(.*)$}
85+
my ( $bn, $br ) = $r =~ m{([^/]+)#(.*)$}
8186
or next;
8287

83-
next unless basename($dest_dir) eq $bn;
88+
next unless $basename eq $bn;
8489

8590
$branch = $br;
8691
delete $repos{$r};
@@ -97,6 +102,9 @@ sub handle_recipe {
97102
print STDERR "$k:$res";
98103
}
99104

105+
push @volumes, " - '$dest_dir:/src/$basename:\${DOCKER_VOLUME_MOUNT_FLAG:-rw}'";
106+
push @{ $workspace->{folders} }, { path => $basename, };
107+
100108
next if $k eq 'core';
101109

102110
my $plugin_dir = $dest_dir;
@@ -120,7 +128,8 @@ sub handle_recipe {
120128
}
121129

122130
for my $l (@$links) {
123-
push @volumes, " - '$plugin_dir/$l:/var/www/cgi-bin/mt/$l'";
131+
push @volumes,
132+
" - '$plugin_dir/$l:/var/www/cgi-bin/mt/$l:\${DOCKER_VOLUME_MOUNT_FLAG:-rw}'";
124133
}
125134
}
126135

@@ -146,12 +155,13 @@ YAML
146155
}
147156

148157
for my $recipe ( split /\s+/, $recipes ) {
149-
my $recipe_file = ( $recipe =~ m{^[/\.]} && -e $recipe )
158+
my $recipe_file
159+
= ( $recipe =~ m{^[/\.]} && -e $recipe )
150160
? realpath($recipe)
151161
: do {
152-
$recipe =~ s{\.yaml\z}{};
153-
$recipe .= '.yaml';
154-
"$recipe_dir/$recipe";
162+
$recipe =~ s{\.yaml\z}{};
163+
$recipe .= '.yaml';
164+
"$recipe_dir/$recipe";
155165
};
156166

157167
# get recipe
@@ -282,8 +292,25 @@ for my $a ( split /\s+/, $archives ) {
282292
handle_recipe( { $basename => { directory => $directory, }, } );
283293
}
284294

295+
{
296+
my ( $ws_fh, $ws_file ) = tmpnam();
297+
print $ws_fh encode_json($workspace);
298+
close $ws_fh;
299+
300+
my ( $fh, $file ) = tmpnam();
301+
print $fh Dump({
302+
version => "3",
303+
services => {
304+
map {
305+
$_ => { volumes => ["$ws_file:/src/mt.code-workspace",], },
306+
} qw(mt httpd)
307+
},
308+
});
309+
push @$yamls, $file;
310+
}
311+
285312
if (@$yamls) {
286-
$env->{DOCKER_COMPOSE_YML_OVERRIDE} = join( ' ', map {"-f $_"} @$yamls );
313+
$env->{DOCKER_COMPOSE_YAML_OVERRIDE} = join( ' ', map {"-f $_"} @$yamls );
287314
}
288315

289316
# output args for make command

mt/common.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,49 @@
11
version: "3"
22
services:
33
mt:
4-
image: ${DOCKER_MT_IMAGE:-movabletype/test:perl-5.28}
4+
build:
5+
context: ${DOCKER_MT_BUILD_CONTEXT:-mt}
6+
dockerfile: ${DOCKER_MT_DOCKERFILE}
7+
args:
8+
- DOCKER_NODEJS_IMAGE=${DOCKER_NODEJS_IMAGE:-node:16.13.2}
9+
- DOCKER_MT_IMAGE=${DOCKER_MT_IMAGE:-movabletype/test:perl-5.28}
510
restart: always
611
working_dir: /var/www/cgi-bin/mt
712
entrypoint: /usr/local/bin/docker-entrypoint.sh
813
environment:
914
NLS_LANG: ${NLS_LANG:-Japanese_Japan.UTF8}
1015
MT_DEV_UPDATE_BRANCH: ${UPDATE_BRANCH:-yes}
1116
DOCKER_MT_SERVICES: ${DOCKER_MT_SERVICES}
17+
APACHE_LOG_DIR: ${APACHE_LOG_DIR:-/tmp/apache2/log}
18+
APACHE_PID_FILE: ${APACHE_PID_FILE:-/tmp/apache2/run/apache2.pid}
1219
volumes:
1320
- "..:/mt-dev"
14-
- "${MT_HOME_PATH:-../../movabletype}:/var/www/cgi-bin/mt"
15-
- "${MT_CONFIG_CGI_SRC_PATH:-../mt-config.cgi-original}:${MT_CONFIG_CGI_DEST_PATH:-/var/www/cgi-bin/mt/mt-config.cgi}"
16-
- "${BASE_SITE_PATH:-site}:/var/www/html"
17-
- "support:/var/www/cgi-bin/mt/mt-static/support"
21+
- "${MT_HOME_PATH:-../../movabletype}:/var/www/cgi-bin/mt:${DOCKER_VOLUME_MOUNT_FLAG:-rw}"
22+
- "${MT_CONFIG_CGI_SRC_PATH:-../mt-config.cgi-original}:${MT_CONFIG_CGI_DEST_PATH:-/var/www/cgi-bin/mt/mt-config.cgi}:${DOCKER_VOLUME_MOUNT_FLAG:-rw}"
23+
- "${BASE_SITE_PATH:-site}:/var/www/html:${DOCKER_VOLUME_MOUNT_FLAG:-rw}"
24+
- "support:/var/www/cgi-bin/mt/mt-static/support:${DOCKER_VOLUME_MOUNT_FLAG:-rw}"
1825
# override entrypoint
1926
- "./docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh"
2027
labels:
2128
mt-dev.service: "mt"
2229

2330
httpd:
24-
image: ${DOCKER_HTTPD_IMAGE:-movabletype/test:php-7.3}
31+
build:
32+
context: ${DOCKER_HTTPD_BUILD_CONTEXT:-httpd}
33+
dockerfile: ${DOCKER_HTTPD_DOCKERFILE}
34+
args:
35+
- DOCKER_HTTPD_IMAGE=${DOCKER_HTTPD_IMAGE:-movabletype/test:php-8.0}
2536
restart: always
2637
entrypoint: "/usr/local/bin/docker-entrypoint.sh"
38+
environment:
39+
APACHE_LOG_DIR: ${APACHE_LOG_DIR:-/tmp/apache2/log}
40+
APACHE_PID_FILE: ${APACHE_PID_FILE:-/tmp/apache2/run/apache2.pid}
2741
volumes:
2842
- "..:/mt-dev"
29-
- "${MT_HOME_PATH:-../../movabletype}:/var/www/cgi-bin/mt"
30-
- "${MT_CONFIG_CGI_SRC_PATH:-../mt-config.cgi-original}:${MT_CONFIG_CGI_DEST_PATH:-/var/www/cgi-bin/mt/mt-config.cgi}"
31-
- "${BASE_SITE_PATH:-site}:/var/www/html"
32-
- "support:/var/www/cgi-bin/mt/mt-static/support"
43+
- "${MT_HOME_PATH:-../../movabletype}:/var/www/cgi-bin/mt:${DOCKER_VOLUME_MOUNT_FLAG:-rw}"
44+
- "${MT_CONFIG_CGI_SRC_PATH:-../mt-config.cgi-original}:${MT_CONFIG_CGI_DEST_PATH:-/var/www/cgi-bin/mt/mt-config.cgi}:${DOCKER_VOLUME_MOUNT_FLAG:-rw}"
45+
- "${BASE_SITE_PATH:-site}:/var/www/html:${DOCKER_VOLUME_MOUNT_FLAG:-rw}"
46+
- "support:/var/www/cgi-bin/mt/mt-static/support:${DOCKER_VOLUME_MOUNT_FLAG:-rw}"
3347
# override entrypoint
3448
- "./docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh"
3549
# proxy setting

0 commit comments

Comments
 (0)