Skip to content

Commit ec901c9

Browse files
Mutagen + code improvements (#81)
* Fixing certificate revoked on Mac * Use Mutagen to bring up core config * Wait for necessary files to be present when building PWA theme. * Remove whitespaces * Mac optimizations - Add volume core-frontend-data for core frontend container - Implement mutagen configuration for both core and frontend dc configs - FIx node container not having wget - Keep maildev configuration in local setup only * Optimize frontend deploy script acquiring process Make them be mounted into frontend container on deploy instead of copied on build * Add mutagen config without frontend container Optimize sync making it two-way-resolved Propagate www-data as default file owner * Move core-frontend-data volume from main compose to core compose * Fix permission issue in app and nginx containers * Rename mutagen compose files to keep originals * Add modified original compose files back * Move core frontend volume declaration to corresponding compose file * Fix user being set as file owner on alpha * Refactor sync sessions - remove nginx session by introducing named volume - extend mutagen permission config with default file mode * Revert not working Mac certificate fix * Typo and ping removal * Remove ping from installed packages * Add mutagen-powered-app container name to resolve container naming issue in yml files * Refactor frontend container compose files Move dependency installation to build script Replace deploy script with single command Remove core-frontend-data volume, mount app-data directly Rename start-with-frontend script * Mount all app-data into nginx * Return magento se:up success check to deploy * Update process file names to the relevant ones * Return dependency installation to FE deploy * Revert demo deploy script changes * Use separate deploy script for Mutagen Remove waiting for composer.json files in main script * Use start-with-mutagen script to wait for fs * Map Mutagen start scripts into containers * Build scripts into containers instead of map * Mount app-data into frontend container * Remove mounting start script from host * Move waiting logic to separate script for FE cont * Apply proper permissions to waiting script * Implement script to wait for fs * Removed links * Moved additional buildstep to separate folder, for quicker build. * Moving global installs to build * Adding new lines in the end to most mutagen files * Added ignores for node_modules and vendor * Added missing max-body size nginx setting * Merged mutagen with ScandiPWA, fixed multiple issues * Updated gitignore with a proper file name * Fix for mutagen lock files * Added proper labels to containers Co-authored-by: negzu <[email protected]>
1 parent 4ade667 commit ec901c9

35 files changed

+343
-323
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ src/*
44
!src/composer.*
55
!.gitignore
66
!**/.gitkeep
7+
mutagen.*.lock

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# hadolint ignore=DL3007
22
FROM scandipwa/php:latest
3-
LABEL maintainer="Scandiweb <[email protected]>"
4-
LABEL authors="Jurijs Jegorovs [email protected]; Ilja Lapkovskis [email protected]"
53

64
# Set bash by default
75
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
@@ -60,7 +58,7 @@ RUN { \
6058
echo 'from no-reply@docker'; \
6159
echo 'account default'; \
6260
} | tee /etc/msmtprc
63-
61+
6462
# Start script, executed upon container creation from image
6563
COPY deploy/start.sh /start.sh
6664
RUN chmod +x /start.sh
@@ -85,4 +83,4 @@ CMD ["/start.sh"]
8583
RUN echo "$(tput setaf 3)php, composer$(tput sgr0)";\
8684
composer diagnose; printf "\n";\
8785
echo "$(tput setaf 3)nodejs, npm$(tput sgr0)";\
88-
npm doctor; printf "\n";
86+
npm doctor; printf "\n";

Makefile

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,11 @@
11
# Define available commands
2-
.PHONY: build full-rebuild push up recreate down cert pull \
3-
down-rm-volumes applogs logs flushall core-up core-down core-logs \
4-
exec
2+
.PHONY: cert
53

64
# Variables
75
current_dir := $(shell pwd)
86
uid := $(shell id -u)
97
gid := $(shell id -g)
108

11-
# Warning! Do not use soft tabs!
12-
up:
13-
docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml up -d
14-
15-
core-up:
16-
docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.core.yml -f docker-compose.ssl.yml up -d
17-
18-
build:
19-
docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml build
20-
21-
pull:
22-
docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml pull
23-
24-
down:
25-
docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml down --remove-orphans
26-
27-
core-down:
28-
docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.core.yml -f docker-compose.ssl.yml down --remove-orphans
29-
30-
down-rm-volumes:
31-
docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml down -v
32-
33-
applogs:
34-
docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml logs -f app
35-
36-
logs:
37-
docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml logs -f
38-
39-
core-logs:
40-
docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.core.yml -f docker-compose.ssl.yml logs -f --tail 100
41-
42-
full-rebuild:
43-
docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml build --pull --no-cache
44-
45-
flushall:
46-
docker-compose -f docker-compose.yml -f docker-compose.local.yml exec varnish varnishadm "ban req.url ~ /"
47-
docker-compose -f docker-compose.yml -f docker-compose.local.yml exec redis redis-cli FLUSHALL
48-
49-
exec:
50-
docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.core.yml -f docker-compose.ssl.yml exec -u user app $(filter-out $@,$(MAKECMDGOALS))
51-
52-
%:
53-
@true
54-
559
cert:
5610
mkdir -p opt/cert
5711
docker run -it --rm --init \

build/frontend/Dockerfile

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
ARG NODEJS_VERSION=10
22

33
FROM node:$NODEJS_VERSION
4-
LABEL authors="Alfred Genkins, Ilja Lapkovskis [email protected]"
54

6-
ARG BASEPATH=/var/www/public
5+
LABEL maintainer="Alfreds Genkins [email protected]"
6+
LABEL author="Ilja Lapkovskis [email protected]"
77

8-
# Set working directory so any relative configuration or scripts wont fail
9-
WORKDIR $BASEPATH
8+
RUN npm install pm2 forever -g
109

1110
COPY start.sh /start.sh
12-
COPY start-core.sh /start-core.sh
1311
RUN chmod +x /start.sh
14-
RUN chmod +x /start-core.sh
15-
16-
CMD ["/bin/bash", "/start.sh"]

build/frontend/start-core.sh

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

build/frontend/start.sh

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,58 @@
11
#!/bin/bash
2+
3+
mutagen="0"
4+
core="0"
5+
6+
helpFunction()
7+
{
8+
echo ""
9+
echo "Usage: $0 [-M] [-C]"
10+
echo -e "\t-M Wait for Mutagen to sync files before start"
11+
echo -e "\t-C Start core watching script"
12+
exit 1 # Exit script after printing help
13+
}
14+
15+
while getopts "MC" opt
16+
do
17+
case "$opt" in
18+
M ) mutagen="1" ;;
19+
C ) core="1" ;;
20+
? ) helpFunction ;;
21+
esac
22+
done
23+
24+
PATH_TO_THEME="/var/www/public"
25+
26+
if [ "$core" = "1" ]
27+
then
28+
PATH_TO_THEME="$PATH_TO_THEME/localmodules/base-theme/"
29+
else
30+
PATH_TO_THEME="$PATH_TO_THEME/app/design/frontend/Scandiweb/pwa/"
31+
fi
32+
33+
if [ -d $PATH_TO_THEME ]
34+
then
35+
cd $PATH_TO_THEME;
36+
else
37+
echo "ERROR: $PATH_TO_THEME is empty!"
38+
exit 1
39+
fi
40+
41+
if [ "$mutagen" = "1" ]
42+
then
43+
echo "Waiting for Mutagen to sync initial files"
44+
while ! [ -f ./package.json -a -f ./package-lock.json ]
45+
do
46+
sleep 2
47+
done
48+
fi
49+
50+
echo "Installing node modules"
251
npm ci
3-
npm install pm2 forever -g
4-
pm2-runtime process.yml
52+
53+
if [ "$core" = "1" ]
54+
then
55+
pm2-runtime process-core.yml
56+
else
57+
pm2-runtime process.yml
58+
fi

build/php/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM ubuntu:bionic
2-
LABEL maintainer="Ilja Lapkovskis [email protected]"
2+
LABEL author="Ilja Lapkovskis [email protected]"
3+
LABEL maintainer="Alfreds Genkins [email protected]"
34

45
ARG COMPOSER_HOME=/var/lib/composer
56
ARG COMPOSER_VERSION=latest
@@ -55,7 +56,7 @@ ENV PHPIZE_DEPS \
5556
libxslt1-dev \
5657
libsodium-dev \
5758
libargon2-0-dev
58-
59+
5960
# Update server packages to latest versions
6061
RUN apt-get -qq update &&\
6162
apt-get -qq dist-upgrade -y &&\

build/rendertron/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM node:10
22

3+
LABEL maintainer="Alfreds Genkins [email protected]"
4+
35
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
46
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
57
# installs, work.

build/varnish/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM debian:stretch-slim
2-
LABEL maintainer="Ilja Lapkovskis admin@scandiweb.com"
2+
LABEL maintainer="Alfreds Genkins alfreds@scandipwa.com"
33
LABEL author="Jurijs Jegorovs [email protected]"
4+
45
ENV DEBIAN_FRONTEND=noninteractive \
56
VARNISH_VERSION=5.2 \
67
VARNISH_VERSION_FLATTEN=52\

build/xdebug/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM scandipwa/base
2-
LABEL authors="Jurijs Jegorovs [email protected]"
3-
LABEL maintainer="Jurijs Jegorovs [email protected]"
2+
3+
LABEL maintainer="Alfreds Genkins [email protected]"
4+
45
ENV DEBIAN_FRONTEND=noninteractive
56

67
# Install required PHP extensions

0 commit comments

Comments
 (0)