Skip to content

Commit b9830ed

Browse files
committed
Added the prepared monarc source code into the image container.
1 parent 8ec0b2f commit b9830ed

File tree

7 files changed

+240
-6
lines changed

7 files changed

+240
-6
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ npm-debug.log
4040
# Cache
4141
*.cache
4242
.docker-initialized
43+
.docker-release-context/
44+
.docker-stage-context/
4345

4446
# Environment files (should be configured separately)
4547
.env

.github/workflows/releases.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,28 @@ jobs:
111111
fail_on_unmatched_files: true
112112
if: startsWith(github.ref, 'refs/tags/')
113113

114+
- name: Prepare app image build context
115+
if: startsWith(github.ref, 'refs/tags/')
116+
run: |
117+
rm -rf .docker-release-context
118+
mkdir -p .docker-release-context
119+
tar \
120+
--exclude .git \
121+
--exclude .github \
122+
--exclude .idea \
123+
--exclude .vscode \
124+
--exclude vagrant \
125+
--exclude wsl \
126+
--exclude INSTALL \
127+
--exclude data \
128+
--exclude .env \
129+
--exclude .env.dev \
130+
--exclude .DS_Store \
131+
--exclude .docker-release-context \
132+
--exclude .docker-stage-context \
133+
-cf - . | tar -xf - -C .docker-release-context
134+
rm -f .docker-release-context/.dockerignore
135+
114136
- name: Set image names
115137
id: image_names
116138
if: startsWith(github.ref, 'refs/tags/')
@@ -153,8 +175,8 @@ jobs:
153175
if: startsWith(github.ref, 'refs/tags/')
154176
uses: docker/build-push-action@v6
155177
with:
156-
context: .
157-
file: ./Dockerfile
178+
context: ./.docker-release-context
179+
file: ./.docker-release-context/Dockerfile.release
158180
push: true
159181
platforms: linux/amd64,linux/arm64
160182
tags: ${{ steps.meta_app.outputs.tags }}

.github/workflows/stage-image.yml

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,96 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v2
1717

18+
- name: install deps
19+
run: sudo apt-get update && sudo apt install -y gettext
20+
21+
# PHP
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: "8.1"
26+
tools: composer:v2.3
27+
extensions: bcmath
28+
29+
- name: Validate composer.json and composer.lock
30+
run: composer validate
31+
32+
- name: Install PHP dependencies
33+
run: composer install --prefer-dist --no-progress --no-suggest --no-dev
34+
35+
- name: Symlink Monarc modules
36+
run: |
37+
mkdir -p module/Monarc
38+
ln -s ../../vendor/monarc/core module/Monarc/Core
39+
ln -s ../../vendor/monarc/frontoffice module/Monarc/FrontOffice
40+
41+
# javascript
42+
- name: Use Node.js 16.x
43+
uses: actions/setup-node@v1
44+
with:
45+
node-version: "16.x"
46+
47+
- uses: oprypin/find-latest-tag@v1
48+
with:
49+
repository: monarc-project/ng-anr
50+
releases-only: true
51+
id: ng_anr_lasttag
52+
53+
- run: echo "ng-anr is at version ${{ steps.ng_anr_lasttag.outputs.tag }}"
54+
55+
- name: Install ng-anr
56+
uses: actions/checkout@v3
57+
with:
58+
repository: monarc-project/ng-anr
59+
ref: ${{ steps.ng_anr_lasttag.outputs.tag }}
60+
path: './node_modules/ng_anr'
61+
62+
- uses: oprypin/find-latest-tag@v1
63+
with:
64+
repository: monarc-project/ng-client
65+
releases-only: true
66+
id: ng_client_lasttag
67+
68+
- run: echo "ng-client is at version ${{ steps.ng_client_lasttag.outputs.tag }}"
69+
70+
- name: Install ng-client
71+
uses: actions/checkout@v3
72+
with:
73+
repository: monarc-project/ng-client
74+
ref: ${{ steps.ng_client_lasttag.outputs.tag }}
75+
path: './node_modules/ng_client'
76+
77+
- name: Install ng-client dependencies
78+
run: |
79+
cd node_modules/ng_client
80+
npm ci
81+
82+
- name: post job
83+
run: |
84+
bash -ex ./scripts/link_modules_resources.sh
85+
bash -ex ./scripts/compile_translations.sh
86+
87+
- name: Prepare app image build context
88+
run: |
89+
rm -rf .docker-stage-context
90+
mkdir -p .docker-stage-context
91+
tar \
92+
--exclude .git \
93+
--exclude .github \
94+
--exclude .idea \
95+
--exclude .vscode \
96+
--exclude vagrant \
97+
--exclude wsl \
98+
--exclude INSTALL \
99+
--exclude data \
100+
--exclude .env \
101+
--exclude .env.dev \
102+
--exclude .DS_Store \
103+
--exclude .docker-stage-context \
104+
--exclude .docker-release-context \
105+
-cf - . | tar -xf - -C .docker-stage-context
106+
rm -f .docker-stage-context/.dockerignore
107+
18108
- name: Set image names
19109
id: image_names
20110
run: |
@@ -51,8 +141,8 @@ jobs:
51141
- name: Build and push app image (stage)
52142
uses: docker/build-push-action@v6
53143
with:
54-
context: .
55-
file: ./Dockerfile
144+
context: ./.docker-stage-context
145+
file: ./.docker-stage-context/Dockerfile.release
56146
push: true
57147
platforms: linux/amd64,linux/arm64
58148
tags: ${{ steps.meta_app_stage.outputs.tags }}
File renamed without changes.

Dockerfile.release

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
FROM ubuntu:22.04
2+
3+
ARG XDEBUG_ENABLED=1
4+
ARG XDEBUG_MODE=debug
5+
ARG XDEBUG_START_WITH_REQUEST=trigger
6+
ARG XDEBUG_CLIENT_HOST=host.docker.internal
7+
ARG XDEBUG_CLIENT_PORT=9003
8+
ARG XDEBUG_IDEKEY=IDEKEY
9+
ARG XDEBUG_DISCOVER_CLIENT_HOST=0
10+
ARG NODE_MAJOR=16
11+
12+
# Prevent interactive prompts during package installation
13+
ENV DEBIAN_FRONTEND=noninteractive
14+
ENV LANGUAGE=en_US.UTF-8
15+
ENV LANG=en_US.UTF-8
16+
ENV LC_ALL=en_US.UTF-8
17+
18+
# Install system dependencies
19+
RUN apt-get update && apt-get upgrade -y && \
20+
packages="vim zip unzip git gettext curl gsfonts mariadb-client apache2 php8.1 php8.1-cli \
21+
php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml \
22+
php8.1-bcmath php8.1-intl php8.1-imagick locales wget ca-certificates gnupg \
23+
build-essential python3 pkg-config libcairo2-dev libpango1.0-dev libjpeg-dev \
24+
libgif-dev librsvg2-dev libpixman-1-dev"; \
25+
if [ "$XDEBUG_ENABLED" = "1" ] || [ "$XDEBUG_ENABLED" = "true" ] || [ "$XDEBUG_ENABLED" = "yes" ]; then \
26+
packages="$packages php8.1-xdebug"; \
27+
fi; \
28+
apt-get install -y $packages && \
29+
locale-gen en_US.UTF-8 && \
30+
apt-get clean && \
31+
rm -rf /var/lib/apt/lists/*
32+
33+
# Configure PHP
34+
RUN sed -i 's/upload_max_filesize = .*/upload_max_filesize = 200M/' /etc/php/8.1/apache2/php.ini && \
35+
sed -i 's/post_max_size = .*/post_max_size = 50M/' /etc/php/8.1/apache2/php.ini && \
36+
sed -i 's/max_execution_time = .*/max_execution_time = 100/' /etc/php/8.1/apache2/php.ini && \
37+
sed -i 's/max_input_time = .*/max_input_time = 223/' /etc/php/8.1/apache2/php.ini && \
38+
sed -i 's/memory_limit = .*/memory_limit = 512M/' /etc/php/8.1/apache2/php.ini && \
39+
sed -i 's/session\.gc_maxlifetime = .*/session.gc_maxlifetime = 604800/' /etc/php/8.1/apache2/php.ini && \
40+
sed -i 's/session\.gc_probability = .*/session.gc_probability = 1/' /etc/php/8.1/apache2/php.ini && \
41+
sed -i 's/session\.gc_divisor = .*/session.gc_divisor = 1000/' /etc/php/8.1/apache2/php.ini
42+
43+
# Configure Xdebug for development
44+
RUN if [ "$XDEBUG_ENABLED" = "1" ] || [ "$XDEBUG_ENABLED" = "true" ] || [ "$XDEBUG_ENABLED" = "yes" ]; then \
45+
echo "zend_extension=xdebug.so" > /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
46+
echo "xdebug.mode=${XDEBUG_MODE}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
47+
echo "xdebug.start_with_request=${XDEBUG_START_WITH_REQUEST}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
48+
echo "xdebug.client_host=${XDEBUG_CLIENT_HOST}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
49+
echo "xdebug.client_port=${XDEBUG_CLIENT_PORT}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
50+
echo "xdebug.discover_client_host=${XDEBUG_DISCOVER_CLIENT_HOST}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
51+
echo "xdebug.idekey=${XDEBUG_IDEKEY}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini; \
52+
fi
53+
54+
# Enable Apache modules
55+
RUN a2enmod rewrite ssl headers
56+
57+
# Set global ServerName to avoid AH00558 warning
58+
RUN echo "ServerName localhost" > /etc/apache2/conf-available/servername.conf \
59+
&& a2enconf servername
60+
61+
# Install Composer
62+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
63+
64+
# Install Node.js and npm
65+
RUN mkdir -p /etc/apt/keyrings && \
66+
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
67+
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
68+
apt-get update && \
69+
apt-get install -y nodejs && \
70+
npm install -g grunt-cli && \
71+
apt-get clean && \
72+
rm -rf /var/lib/apt/lists/*
73+
74+
# Set working directory
75+
WORKDIR /var/www/html/monarc
76+
77+
# Configure Apache
78+
RUN echo '<VirtualHost *:80>\n\
79+
ServerName localhost\n\
80+
DocumentRoot /var/www/html/monarc/public\n\
81+
\n\
82+
<Directory /var/www/html/monarc/public>\n\
83+
DirectoryIndex index.php\n\
84+
AllowOverride All\n\
85+
Require all granted\n\
86+
</Directory>\n\
87+
\n\
88+
<IfModule mod_headers.c>\n\
89+
Header always set X-Content-Type-Options nosniff\n\
90+
Header always set X-XSS-Protection "1; mode=block"\n\
91+
Header always set X-Robots-Tag none\n\
92+
Header always set X-Frame-Options SAMEORIGIN\n\
93+
</IfModule>\n\
94+
\n\
95+
SetEnv APP_ENV development\n\
96+
SetEnv APP_DIR /var/www/html/monarc\n\
97+
</VirtualHost>' > /etc/apache2/sites-available/000-default.conf
98+
99+
# Allow Apache override to all
100+
RUN sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf
101+
102+
# Create necessary directories
103+
RUN mkdir -p /var/www/html/monarc/data/cache \
104+
/var/www/html/monarc/data/LazyServices/Proxy \
105+
/var/www/html/monarc/data/DoctrineORMModule/Proxy \
106+
/var/www/html/monarc/data/import/files
107+
108+
# Copy entrypoint script
109+
COPY docker-entrypoint.sh /usr/local/bin/
110+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
111+
112+
# Copy fully prepared application source into the image.
113+
# The workflow pre-build step ensures vendor/node_modules/resources are already ready.
114+
COPY . /var/www/html/monarc
115+
RUN chown -R www-data:www-data /var/www/html/monarc
116+
117+
EXPOSE 80
118+
119+
ENTRYPOINT ["docker-entrypoint.sh"]
120+
CMD ["apachectl", "-D", "FOREGROUND"]

README.docker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ For better performance on macOS and Windows:
394394
- Memory: 8GB or more
395395
- Swap: 2GB or more
396396

397-
3. **Enable caching**: The Dockerfile uses apt cache and composer optimizations.
397+
3. **Enable caching**: `Dockerfile.dev` uses apt cache and composer optimizations.
398398

399399
## Comparison with Vagrant
400400

docker-compose.dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ services:
8484
monarcfoapp:
8585
build:
8686
context: .
87-
dockerfile: Dockerfile
87+
dockerfile: Dockerfile.dev
8888
args:
8989
NODE_MAJOR: ${NODE_MAJOR:-16}
9090
XDEBUG_ENABLED: ${XDEBUG_ENABLED:-1}

0 commit comments

Comments
 (0)