Skip to content

Commit 2e59da0

Browse files
author
Ruslan Baidan
committed
Fixed the docker process to be able run the application.
1 parent 1c71d78 commit 2e59da0

File tree

12 files changed

+301
-209
lines changed

12 files changed

+301
-209
lines changed

.env.dev

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@ DBNAME_COMMON=monarc_common
44
DBNAME_MASTER=monarc_master
55
DBUSER_MONARC=sqlmonarcuser
66
DBPASSWORD_MONARC=sqlmonarcuser
7+
8+
# Optional: set to 0/false/no to disable Xdebug in the image build
9+
XDEBUG_ENABLED=1
10+
XDEBUG_MODE=debug
11+
XDEBUG_START_WITH_REQUEST=trigger
12+
# On Linux, set XDEBUG_CLIENT_HOST to your Docker bridge (often 172.17.0.1).
13+
XDEBUG_CLIENT_HOST=host.docker.internal
14+
XDEBUG_CLIENT_PORT=9003
15+
XDEBUG_IDEKEY=IDEKEY
16+
XDEBUG_DISCOVER_CLIENT_HOST=0

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ vagrant/.vagrant/
2222
vagrant/*.log
2323
.env
2424
.docker-initialized
25+
docker/db_data

.vscode/launch.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Attach to Chrome",
9+
"port": 9222,
10+
"request": "attach",
11+
"type": "chrome",
12+
"webRoot": "${workspaceFolder}"
13+
},
14+
{
15+
"name": "Listen for Xdebug",
16+
"type": "php",
17+
"request": "launch",
18+
"port": 9003,
19+
"pathMappings": {
20+
"/var/www/html/monarc": "${workspaceFolder}"
21+
}
22+
},
23+
{
24+
"name": "Launch currently open script",
25+
"type": "php",
26+
"request": "launch",
27+
"program": "${file}",
28+
"cwd": "${fileDirname}",
29+
"port": 0,
30+
"runtimeArgs": [
31+
"-dxdebug.start_with_request=yes"
32+
],
33+
"env": {
34+
"XDEBUG_MODE": "debug,develop",
35+
"XDEBUG_CONFIG": "client_port=${port}"
36+
}
37+
},
38+
{
39+
"name": "Launch Built-in web server",
40+
"type": "php",
41+
"request": "launch",
42+
"runtimeArgs": [
43+
"-dxdebug.mode=debug",
44+
"-dxdebug.start_with_request=yes",
45+
"-S",
46+
"localhost:0"
47+
],
48+
"program": "",
49+
"cwd": "${workspaceRoot}",
50+
"port": 9003,
51+
"serverReadyAction": {
52+
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
53+
"uriFormat": "http://localhost:%s",
54+
"action": "openExternally"
55+
}
56+
}
57+
]
58+
}

Dockerfile

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
FROM ubuntu:22.04
22

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+
311
# Prevent interactive prompts during package installation
412
ENV DEBIAN_FRONTEND=noninteractive
513
ENV LANGUAGE=en_US.UTF-8
@@ -8,33 +16,13 @@ ENV LC_ALL=en_US.UTF-8
816

917
# Install system dependencies
1018
RUN apt-get update && apt-get upgrade -y && \
11-
apt-get install -y \
12-
vim \
13-
zip \
14-
unzip \
15-
git \
16-
gettext \
17-
curl \
18-
gsfonts \
19-
mariadb-client \
20-
apache2 \
21-
php8.1 \
22-
php8.1-cli \
23-
php8.1-common \
24-
php8.1-mysql \
25-
php8.1-zip \
26-
php8.1-gd \
27-
php8.1-mbstring \
28-
php8.1-curl \
29-
php8.1-xml \
30-
php8.1-bcmath \
31-
php8.1-intl \
32-
php8.1-imagick \
33-
php8.1-xdebug \
34-
locales \
35-
wget \
36-
ca-certificates \
37-
gnupg && \
19+
packages="vim zip unzip git gettext curl gsfonts mariadb-client apache2 php8.1 php8.1-cli \
20+
php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml \
21+
php8.1-bcmath php8.1-intl php8.1-imagick locales wget ca-certificates gnupg"; \
22+
if [ "$XDEBUG_ENABLED" = "1" ] || [ "$XDEBUG_ENABLED" = "true" ] || [ "$XDEBUG_ENABLED" = "yes" ]; then \
23+
packages="$packages php8.1-xdebug"; \
24+
fi; \
25+
apt-get install -y $packages && \
3826
locale-gen en_US.UTF-8 && \
3927
apt-get clean && \
4028
rm -rf /var/lib/apt/lists/*
@@ -50,23 +38,32 @@ RUN sed -i 's/upload_max_filesize = .*/upload_max_filesize = 200M/' /etc/php/8.1
5038
sed -i 's/session\\.gc_divisor = .*/session.gc_divisor = 1000/' /etc/php/8.1/apache2/php.ini
5139

5240
# Configure Xdebug for development
53-
RUN echo "zend_extension=xdebug.so" > /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
54-
echo "xdebug.mode=debug" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
55-
echo "xdebug.discover_client_host=1" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
56-
echo "xdebug.idekey=IDEKEY" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini
41+
RUN if [ "$XDEBUG_ENABLED" = "1" ] || [ "$XDEBUG_ENABLED" = "true" ] || [ "$XDEBUG_ENABLED" = "yes" ]; then \
42+
echo "zend_extension=xdebug.so" > /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
43+
echo "xdebug.mode=${XDEBUG_MODE}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
44+
echo "xdebug.start_with_request=${XDEBUG_START_WITH_REQUEST}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
45+
echo "xdebug.client_host=${XDEBUG_CLIENT_HOST}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
46+
echo "xdebug.client_port=${XDEBUG_CLIENT_PORT}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
47+
echo "xdebug.discover_client_host=${XDEBUG_DISCOVER_CLIENT_HOST}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
48+
echo "xdebug.idekey=${XDEBUG_IDEKEY}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini; \
49+
fi
5750

5851
# Enable Apache modules
5952
RUN a2enmod rewrite ssl headers
6053

54+
# Set global ServerName to avoid AH00558 warning
55+
RUN echo "ServerName localhost" > /etc/apache2/conf-available/servername.conf \
56+
&& a2enconf servername
57+
6158
# Install Composer
6259
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
6360

6461
# Install Node.js and npm
6562
RUN mkdir -p /etc/apt/keyrings && \
6663
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_15.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
64+
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
6865
apt-get update && \
69-
apt-get install -y nodejs npm && \
66+
apt-get install -y nodejs && \
7067
npm install -g grunt-cli && \
7168
apt-get clean && \
7269
rm -rf /var/lib/apt/lists/*

INSTALL/INSTALL.docker.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ This document provides installation instructions for setting up MONARC BackOffic
99
git clone https://github.com/monarc-project/MonarcAppBO
1010
cd MonarcAppBO
1111

12-
# Start with the helper script (recommended)
13-
./docker-dev.sh start
12+
# Start with Makefile (recommended)
13+
make start
14+
# Optional: use ENV to select docker-compose.<ENV>.yml (default: dev)
15+
# make start ENV=prod
1416

1517
# Or use docker-compose directly
1618
cp .env.dev .env
@@ -97,7 +99,7 @@ chmod -R 775 /var/www/html/monarc/data
9799
Check the logs:
98100

99101
```bash
100-
./docker-dev.sh logs
102+
make logs
101103
# or
102104
docker compose -f docker-compose.dev.yml logs
103105
```
@@ -107,7 +109,7 @@ docker compose -f docker-compose.dev.yml logs
107109
To start completely fresh:
108110

109111
```bash
110-
./docker-dev.sh reset
112+
make reset
111113
# or
112114
docker compose -f docker-compose.dev.yml down -v
113115
```
@@ -116,27 +118,27 @@ docker compose -f docker-compose.dev.yml down -v
116118

117119
### View Logs
118120
```bash
119-
./docker-dev.sh logs
121+
make logs
120122
```
121123

122124
### Access Container Shell
123125
```bash
124-
./docker-dev.sh shell
126+
make shell
125127
```
126128

127129
### Access Database
128130
```bash
129-
./docker-dev.sh db
131+
make db
130132
```
131133

132134
### Stop Services
133135
```bash
134-
./docker-dev.sh stop
136+
make stop
135137
```
136138

137139
### Restart Services
138140
```bash
139-
./docker-dev.sh restart
141+
make restart
140142
```
141143

142144
## Comparison with Other Installation Methods

Makefile

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
.DEFAULT_GOAL := help
2+
3+
SHELL := /bin/bash
4+
5+
ENV ?= dev
6+
COMPOSE_FILE ?= docker-compose.$(ENV).yml
7+
COMPOSE := docker compose -f $(COMPOSE_FILE)
8+
9+
GREEN := \033[0;32m
10+
YELLOW := \033[1;33m
11+
RED := \033[0;31m
12+
NC := \033[0m
13+
14+
.PHONY: help check-env start stop restart logs logs-app shell db reset status
15+
16+
help:
17+
@printf "%b\n" "$(GREEN)MONARC BackOffice Docker Development Environment Manager$(NC)"
18+
@printf "\n%b\n" "Usage: make <command>"
19+
@printf "%b\n" "Environment: ENV=<name> (default: dev, uses docker-compose.<name>.yml)"
20+
@printf "\n%b\n" "Commands:"
21+
@printf " %-12s %s\n" "start" "Start all services (builds on first run)"
22+
@printf " %-12s %s\n" "stop" "Stop all services"
23+
@printf " %-12s %s\n" "restart" "Restart all services"
24+
@printf " %-12s %s\n" "logs" "View logs from all services"
25+
@printf " %-12s %s\n" "logs-app" "View logs from MONARC application"
26+
@printf " %-12s %s\n" "shell" "Open a shell in the MONARC container"
27+
@printf " %-12s %s\n" "db" "Open MySQL client in the database"
28+
@printf " %-12s %s\n" "reset" "Reset everything (removes all data)"
29+
@printf " %-12s %s\n" "status" "Show status of all services"
30+
31+
check-env:
32+
@if [ ! -f .env ]; then \
33+
printf "%b\n" "$(YELLOW)No .env file found. Creating from .env.dev...$(NC)"; \
34+
cp .env.dev .env; \
35+
printf "%b\n" "$(GREEN).env file created. You can edit it to customize configuration.$(NC)"; \
36+
fi
37+
38+
start: check-env
39+
@printf "%b\n" "$(GREEN)Starting MONARC BackOffice development environment...$(NC)"
40+
@$(COMPOSE) up -d --build
41+
@printf "%b\n" "$(GREEN)Services started!$(NC)"
42+
@printf "%b\n" "MONARC BackOffice: http://localhost:5002"
43+
@printf "\n%b\n" "$(YELLOW)To view logs: make logs ENV=$(ENV)$(NC)"
44+
45+
stop:
46+
@printf "%b\n" "$(YELLOW)Stopping all services...$(NC)"
47+
@$(COMPOSE) stop
48+
@printf "%b\n" "$(GREEN)Services stopped.$(NC)"
49+
50+
restart:
51+
@printf "%b\n" "$(YELLOW)Restarting all services...$(NC)"
52+
@$(COMPOSE) restart
53+
@printf "%b\n" "$(GREEN)Services restarted.$(NC)"
54+
55+
logs:
56+
@$(COMPOSE) logs -f
57+
58+
logs-app:
59+
@$(COMPOSE) logs -f monarc
60+
61+
shell:
62+
@printf "%b\n" "$(GREEN)Opening shell in MONARC container...$(NC)"
63+
@docker exec -it monarc-bo-app bash
64+
65+
db:
66+
@printf "%b\n" "$(GREEN)Opening MySQL client...$(NC)"
67+
@if [ -f .env ]; then \
68+
export $$(grep -v '^#' .env | xargs); \
69+
fi; \
70+
export MYSQL_PWD="$${DBPASSWORD_MONARC:-sqlmonarcuser}"; \
71+
docker exec -it monarc-bo-db mysql -u"$${DBUSER_MONARC:-sqlmonarcuser}" "$${DBNAME_COMMON:-monarc_common}"
72+
73+
reset:
74+
@printf "%b\n" "$(RED)WARNING: This will remove all data!$(NC)"; \
75+
read -p "Are you sure? (yes/no): " confirm; \
76+
if [ "$$confirm" = "yes" ]; then \
77+
printf "%b\n" "$(YELLOW)Stopping and removing all containers, volumes, and data...$(NC)"; \
78+
$(COMPOSE) down -v; \
79+
printf "%b\n" "$(GREEN)Reset complete. Run 'make start' to start fresh.$(NC)"; \
80+
else \
81+
printf "%b\n" "$(GREEN)Reset cancelled.$(NC)"; \
82+
fi
83+
84+
status:
85+
@$(COMPOSE) ps

0 commit comments

Comments
 (0)