Skip to content

Commit 1afec7f

Browse files
MCLOUD-7977: Add manual sync mode (#48)
1 parent 2c1c36f commit 1afec7f

File tree

68 files changed

+709
-516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+709
-516
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
/auth.json
77
/_workdir
88
/_workdir_cache
9+
/venv
10+
/*.code-workspace
911
.phpunit.result.cache

LICENSE_MIT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) Meanbee and Taylor Otwell
3+
Copyright (c) Meanbee, Taylor Otwell and Mage Inferno
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

bin/init-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ domain_is_valid()
5555

5656
composer_install()
5757
{
58-
docker run --rm -e "MAGENTO_ROOT=/app" -v "$(pwd)":/app -v ~/.composer/cache:/root/.composer/cache "magento/magento-cloud-docker-php:${PHP_VERSION}-cli-${IMAGE_VERSION}" composer install --ansi
58+
docker run --rm -e "MAGENTO_ROOT=/app" -v "$(pwd)":/app -v ~/.composer/cache:/composer/cache "magento/magento-cloud-docker-php:${PHP_VERSION}-cli-${IMAGE_VERSION}" composer install --ansi
5959
}
6060

6161
add_host()

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"require": {
1111
"php": "^7.2",
1212
"ext-json": "*",
13-
"composer/composer": "^1.0",
13+
"composer/composer": "^1.0||^2.0",
1414
"composer/semver": "^1.0",
1515
"illuminate/config": "^5.5",
1616
"symfony/config": "^4.4",

dist/bin/magento-docker

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,60 @@ USAGE="Magento Cloud Docker
2424
php 7.2 run a command in a PHP 7.2 container
2525
php 7.3 run a command in a PHP 7.3 container
2626
php 7.4 run a command in a PHP 7.4 container
27+
copy-to copy to container (use --all or specific file/directory)
28+
copy-from copy from container (use --all or specific file/directory)
29+
fix-owns fix ownership to www:www
2730
2831
\033[33mOptions:\033[0m
2932
-h show this help text\n"
3033

34+
function fix-owns() {
35+
if [ -z "$1" ]; then
36+
docker-compose exec -u root -T fpm chown -R www:www /app
37+
else
38+
docker-compose exec -u root -T fpm chown -R www:www /app/"$1"
39+
fi
40+
}
41+
42+
function copy-to() {
43+
[ -z "$1" ] && echo "Please specify a directory or file to copy to container (ex. vendor, --all)" && exit
44+
45+
if [ "$1" == "--all" ]; then
46+
docker cp "./" "$(docker-compose ps -q fpm | awk '{print $1}')":/app/
47+
echo "Completed copying all files from host to container"
48+
fix-owns
49+
else
50+
if [ -f "../$1" ]; then
51+
docker cp "./${1}" "$(docker-compose ps -q fpm | awk '{print $1}')":/app/"$1"
52+
else
53+
docker cp "./${1}" "$(docker-compose ps -q fpm | awk '{print $1}')":/app/"$(dirname "$1")"
54+
fi
55+
echo "Completed copying $1 from host to container"
56+
fix-owns "$1"
57+
fi
58+
}
59+
60+
function copy-from() {
61+
[ -z "$1" ] && echo "Please specify a directory or file to copy from container (ex. vendor, --all)" && exit
62+
63+
if [ "$1" == "--all" ]; then
64+
docker cp "$(docker-compose ps -q fpm | awk '{print $1}')":/app/ "./"
65+
echo "Completed copying all files from container to host"
66+
else
67+
if [ -f "$1" ]; then
68+
docker cp "$(docker-compose ps -q fpm | awk '{print $1}')":/app/"$1" "./$1"
69+
else
70+
docker cp "$(docker-compose ps -q fpm | awk '{print $1}')":/app/"$1" "./$(dirname "$1")"
71+
fi
72+
echo "Completed copying $1 from container to host"
73+
fi
74+
}
75+
3176
if [ ${#@} -ne 0 ]; then
3277
for arg in "$@"; do
3378
if [ "${arg#"-h"}" = "" ]; then
3479
printf "$USAGE"
35-
exit 0;
80+
exit 0
3681
fi
3782
done
3883
fi;
@@ -95,7 +140,7 @@ case "$1" in
95140
version="$2"
96141
shift 2
97142
# allow ssh-agent forwarding for composer.json files that need access to private repos
98-
if [[ $(uname) = Darwin ]]; then
143+
if [[ $(uname) == Darwin ]]; then
99144
# https://docs.docker.com/docker-for-mac/osxfs/#ssh-agent-forwarding (D4M > 2.2)
100145
export SSH_AUTH_SOCK="/run/host-services/ssh-auth.sock"
101146
fi
@@ -104,7 +149,17 @@ case "$1" in
104149
--mount "type=bind,src=$SSH_AUTH_SOCK,target=$SSH_AUTH_SOCK" -e SSH_AUTH_SOCK="$SSH_AUTH_SOCK" \
105150
"magento/magento-cloud-docker-php:${version}-cli-1.1" "$@"
106151
;;
152+
copy-to)
153+
copy-to $2
154+
;;
155+
copy-from)
156+
copy-from $2
157+
;;
158+
fix-owns)
159+
fix-owns
160+
;;
107161
*)
108162
printf "$USAGE"
109-
exit 0;
163+
exit 0
164+
;;
110165
esac

images/php/7.2-cli/Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# This file is automatically generated. Do not edit directly. #
22
FROM php:7.2-cli
3-
ARG GOSU_VERSION=1.11
3+
ARG COMPOSER_VERSION=1.10.22
44

55
ENV COMPOSER_MEMORY_LIMIT -1
66
ENV PHP_MEMORY_LIMIT 2G
77
ENV MAGENTO_ROOT /app
88
ENV DEBUG false
99
ENV MAGENTO_RUN_MODE production
10-
ENV UPDATE_UID_GID false
1110
ENV COMPOSER_ALLOW_SUPERUSER 1
11+
ENV COMPOSER_HOME /composer
1212
ENV ENABLE_SENDMAIL true
1313

1414
ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl
@@ -164,7 +164,7 @@ ADD etc/mail.ini /usr/local/etc/php/conf.d/zz-mail.ini
164164
ADD etc/php-gnupg.ini /usr/local/etc/php/conf.d/gnupg.ini
165165

166166
# Get composer installed to /usr/local/bin/composer
167-
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --version=1.10.22 --filename=composer
167+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --version=${COMPOSER_VERSION} --filename=composer
168168

169169
ADD bin/* /usr/local/bin/
170170

@@ -189,10 +189,12 @@ RUN mkdir -p ${MAGENTO_ROOT}
189189

190190
VOLUME ${MAGENTO_ROOT}
191191

192-
ENTRYPOINT ["/docker-entrypoint.sh"]
192+
RUN chown -R www:www /usr/local /var/www /var/log /usr/local/etc/php/conf.d ${MAGENTO_ROOT} /composer
193193

194-
USER root
194+
ENTRYPOINT ["/docker-entrypoint.sh"]
195195

196196
WORKDIR ${MAGENTO_ROOT}
197197

198+
USER root
199+
198200
CMD ["bash"]

images/php/7.2-cli/docker-entrypoint.sh

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,6 @@
22

33
[ "$DEBUG" = "true" ] && set -x
44

5-
# If asked, we'll ensure that the www is set to the same uid/gid as the
6-
# mounted volume. This works around permission issues with virtualbox shared
7-
# folders.
8-
if [[ "$UPDATE_UID_GID" = "true" ]]; then
9-
echo "Updating www uid and gid"
10-
11-
DOCKER_UID=`stat -c "%u" $MAGENTO_ROOT`
12-
DOCKER_GID=`stat -c "%g" $MAGENTO_ROOT`
13-
14-
INCUMBENT_USER=`getent passwd $DOCKER_UID | cut -d: -f1`
15-
INCUMBENT_GROUP=`getent group $DOCKER_GID | cut -d: -f1`
16-
17-
echo "Docker: uid = $DOCKER_UID, gid = $DOCKER_GID"
18-
echo "Incumbent: user = $INCUMBENT_USER, group = $INCUMBENT_GROUP"
19-
20-
# Once we've established the ids and incumbent ids then we need to free them
21-
# up (if necessary) and then make the change to www.
22-
23-
[ ! -z "${INCUMBENT_USER}" ] && usermod -u 99$DOCKER_UID $INCUMBENT_USER
24-
usermod -u $DOCKER_UID www
25-
26-
[ ! -z "${INCUMBENT_GROUP}" ] && groupmod -g 99$DOCKER_GID $INCUMBENT_GROUP
27-
groupmod -g $DOCKER_GID www
28-
fi
29-
30-
# Ensure our Magento directory exists
31-
mkdir -p $MAGENTO_ROOT
32-
335
CRON_LOG=/var/log/cron.log
346

357
if [ ! -z "${CRONTAB}" ]; then
@@ -66,7 +38,6 @@ if [ -x "$(command -v ${PHP_EXT_COM_ON})" ] && [ ! -z "${PHP_EXTENSIONS}" ]; the
6638
${PHP_EXT_COM_ON} ${PHP_EXTENSIONS}
6739
fi
6840

69-
7041
# Configure composer
7142
[ ! -z "${COMPOSER_VERSION}" ] && \
7243
composer self-update $COMPOSER_VERSION

images/php/7.2-fpm/Dockerfile

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
# This file is automatically generated. Do not edit directly. #
22
FROM php:7.2-fpm
3-
ARG GOSU_VERSION=1.11
43

54
ENV PHP_MEMORY_LIMIT 2G
65
ENV MAGENTO_ROOT /app
76
ENV DEBUG false
87
ENV MAGENTO_RUN_MODE production
98
ENV UPLOAD_MAX_FILESIZE 64M
10-
ENV UPDATE_UID_GID false
119
ENV ENABLE_SENDMAIL true
1210

1311
ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl
@@ -136,19 +134,14 @@ RUN cd /tmp \
136134
&& rm -rf ./ioncube \
137135
&& rm ioncube_loaders_lin_x86-64.tar.gz
138136

139-
RUN groupadd -g 1000 www && useradd -g 1000 -u 1000 -d ${MAGENTO_ROOT} -s /bin/bash www
140-
141137
COPY etc/php-fpm.ini /usr/local/etc/php/conf.d/zz-magento.ini
142138
COPY etc/php-xdebug.ini /usr/local/etc/php/conf.d/zz-xdebug-settings.ini
143139
COPY etc/php-pcov.ini /usr/local/etc/php/conf.d/zz-pcov-settings.ini
144140
COPY etc/mail.ini /usr/local/etc/php/conf.d/zz-mail.ini
145141
COPY etc/php-fpm.conf /usr/local/etc/
146142
COPY etc/php-gnupg.ini /usr/local/etc/php/conf.d/gnupg.ini
147143

148-
COPY fpm-healthcheck.sh /usr/local/bin/fpm-healthcheck.sh
149-
RUN ["chmod", "+x", "/usr/local/bin/fpm-healthcheck.sh"]
150-
151-
HEALTHCHECK --retries=3 CMD ["bash", "/usr/local/bin/fpm-healthcheck.sh"]
144+
RUN groupadd -g 1000 www && useradd -g 1000 -u 1000 -d ${MAGENTO_ROOT} -s /bin/bash www
152145

153146
COPY docker-entrypoint.sh /docker-entrypoint.sh
154147
RUN ["chmod", "+x", "/docker-entrypoint.sh"]
@@ -157,10 +150,12 @@ RUN mkdir -p ${MAGENTO_ROOT}
157150

158151
VOLUME ${MAGENTO_ROOT}
159152

160-
ENTRYPOINT ["/docker-entrypoint.sh"]
153+
RUN chown -R www:www /usr/local /var/www /var/log /usr/local/etc/php/conf.d ${MAGENTO_ROOT}
161154

162-
USER root
155+
ENTRYPOINT ["/docker-entrypoint.sh"]
163156

164157
WORKDIR ${MAGENTO_ROOT}
165158

159+
USER root
160+
166161
CMD ["php-fpm", "-R"]

images/php/7.2-fpm/docker-entrypoint.sh

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,6 @@
22

33
[ "$DEBUG" = "true" ] && set -x
44

5-
# If asked, we'll ensure that the www is set to the same uid/gid as the
6-
# mounted volume. This works around permission issues with virtualbox shared
7-
# folders.
8-
if [[ "$UPDATE_UID_GID" = "true" ]]; then
9-
echo "Updating www uid and gid"
10-
11-
DOCKER_UID=`stat -c "%u" $MAGENTO_ROOT`
12-
DOCKER_GID=`stat -c "%g" $MAGENTO_ROOT`
13-
14-
INCUMBENT_USER=`getent passwd $DOCKER_UID | cut -d: -f1`
15-
INCUMBENT_GROUP=`getent group $DOCKER_GID | cut -d: -f1`
16-
17-
echo "Docker: uid = $DOCKER_UID, gid = $DOCKER_GID"
18-
echo "Incumbent: user = $INCUMBENT_USER, group = $INCUMBENT_GROUP"
19-
20-
# Once we've established the ids and incumbent ids then we need to free them
21-
# up (if necessary) and then make the change to www.
22-
23-
[ ! -z "${INCUMBENT_USER}" ] && usermod -u 99$DOCKER_UID $INCUMBENT_USER
24-
usermod -u $DOCKER_UID www
25-
26-
[ ! -z "${INCUMBENT_GROUP}" ] && groupmod -g 99$DOCKER_GID $INCUMBENT_GROUP
27-
groupmod -g $DOCKER_GID www
28-
fi
29-
30-
# Ensure our Magento directory exists
31-
mkdir -p $MAGENTO_ROOT
32-
335
PHP_EXT_DIR=/usr/local/etc/php/conf.d
346

357
# Configure Sendmail if required

images/php/7.2-fpm/fpm-healthcheck.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)