Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Git files
.git
.gitignore
.github

# Documentation
README.md
CHANGELOG.md
AUTHORS
LICENSE
SECURITY.md
*.md

# Development files
vagrant/
wsl/
INSTALL/
.idea
.vscode
.DS_Store

# Dependencies (will be installed in container)
vendor/
node_modules/

# Data directories (will be mounted as volumes)
data/

# Build artifacts
public/css/
public/js/
public/img/
public/flags/
public/views/

# Logs
*.log
npm-debug.log

# Cache
*.cache
.docker-initialized

# Environment files (should be configured separately)
.env
.env.dev
39 changes: 39 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# MariaDB Configuration
DBHOST=fodb
DBPORT_HOST=3307
DBPASSWORD_ADMIN=root
DBNAME_COMMON=monarc_common
DBNAME_CLI=monarc_cli
DBUSER_MONARC=sqlmonarcuser
DBPASSWORD_MONARC=sqlmonarcuser
# Set USE_BO_COMMON=1 and DBHOST to the BackOffice DB host to reuse monarc_common.
USE_BO_COMMON=1

# Shared Docker network name (must exist when using external network)
MONARC_NETWORK_NAME=monarc-network

# Node.js major version for frontend build tooling
NODE_MAJOR=16

# Optional: set to 0/false/no to disable Xdebug in the image build
XDEBUG_ENABLED=1
XDEBUG_MODE=debug
XDEBUG_START_WITH_REQUEST=trigger
# On Linux, set XDEBUG_CLIENT_HOST to your Docker bridge (often 172.17.0.1).
XDEBUG_CLIENT_HOST=host.docker.internal
XDEBUG_CLIENT_PORT=9003
XDEBUG_IDEKEY=IDEKEY
XDEBUG_DISCOVER_CLIENT_HOST=0

# Stats Service Configuration
STATS_HOST=0.0.0.0
STATS_PORT=5005
STATS_DB_NAME=statsservice
STATS_DB_USER=sqlmonarcuser
STATS_DB_PASSWORD=sqlmonarcuser
# Generate a random secret key for production use:
# openssl rand -hex 32
STATS_SECRET_KEY=changeme_generate_random_secret_key_for_production
# Stats API Key - Leave empty on first run, it will be generated by the stats service
# After first run, get it from the stats service logs or container
STATS_API_KEY=
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ bin/
data/*
!data/fonts
.docker/mariaDb/data/*
.env
.docker-initialized
docker/db_data
.vscode
115 changes: 115 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
FROM ubuntu:22.04

ARG XDEBUG_ENABLED=1
ARG XDEBUG_MODE=debug
ARG XDEBUG_START_WITH_REQUEST=trigger
ARG XDEBUG_CLIENT_HOST=host.docker.internal
ARG XDEBUG_CLIENT_PORT=9003
ARG XDEBUG_IDEKEY=IDEKEY
ARG XDEBUG_DISCOVER_CLIENT_HOST=0
ARG NODE_MAJOR=16

# Prevent interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
ENV LANGUAGE=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8

# Install system dependencies
RUN apt-get update && apt-get upgrade -y && \
packages="vim zip unzip git gettext curl gsfonts mariadb-client apache2 php8.1 php8.1-cli \
php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml \
php8.1-bcmath php8.1-intl php8.1-imagick locales wget ca-certificates gnupg \
build-essential python3 pkg-config libcairo2-dev libpango1.0-dev libjpeg-dev \
libgif-dev librsvg2-dev libpixman-1-dev"; \
if [ "$XDEBUG_ENABLED" = "1" ] || [ "$XDEBUG_ENABLED" = "true" ] || [ "$XDEBUG_ENABLED" = "yes" ]; then \
packages="$packages php8.1-xdebug"; \
fi; \
apt-get install -y $packages && \
locale-gen en_US.UTF-8 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Configure PHP
RUN sed -i 's/upload_max_filesize = .*/upload_max_filesize = 200M/' /etc/php/8.1/apache2/php.ini && \
sed -i 's/post_max_size = .*/post_max_size = 50M/' /etc/php/8.1/apache2/php.ini && \
sed -i 's/max_execution_time = .*/max_execution_time = 100/' /etc/php/8.1/apache2/php.ini && \
sed -i 's/max_input_time = .*/max_input_time = 223/' /etc/php/8.1/apache2/php.ini && \
sed -i 's/memory_limit = .*/memory_limit = 512M/' /etc/php/8.1/apache2/php.ini && \
sed -i 's/session\.gc_maxlifetime = .*/session.gc_maxlifetime = 604800/' /etc/php/8.1/apache2/php.ini && \
sed -i 's/session\.gc_probability = .*/session.gc_probability = 1/' /etc/php/8.1/apache2/php.ini && \
sed -i 's/session\.gc_divisor = .*/session.gc_divisor = 1000/' /etc/php/8.1/apache2/php.ini

# Configure Xdebug for development
RUN if [ "$XDEBUG_ENABLED" = "1" ] || [ "$XDEBUG_ENABLED" = "true" ] || [ "$XDEBUG_ENABLED" = "yes" ]; then \
echo "zend_extension=xdebug.so" > /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
echo "xdebug.mode=${XDEBUG_MODE}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
echo "xdebug.start_with_request=${XDEBUG_START_WITH_REQUEST}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
echo "xdebug.client_host=${XDEBUG_CLIENT_HOST}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
echo "xdebug.client_port=${XDEBUG_CLIENT_PORT}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
echo "xdebug.discover_client_host=${XDEBUG_DISCOVER_CLIENT_HOST}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini && \
echo "xdebug.idekey=${XDEBUG_IDEKEY}" >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini; \
fi

# Enable Apache modules
RUN a2enmod rewrite ssl headers

# Set global ServerName to avoid AH00558 warning
RUN echo "ServerName localhost" > /etc/apache2/conf-available/servername.conf \
&& a2enconf servername

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Install Node.js and npm
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
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 && \
apt-get update && \
apt-get install -y nodejs && \
npm install -g grunt-cli && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /var/www/html/monarc

# Configure Apache
RUN echo '<VirtualHost *:80>\n\
ServerName localhost\n\
DocumentRoot /var/www/html/monarc/public\n\
\n\
<Directory /var/www/html/monarc/public>\n\
DirectoryIndex index.php\n\
AllowOverride All\n\
Require all granted\n\
</Directory>\n\
\n\
<IfModule mod_headers.c>\n\
Header always set X-Content-Type-Options nosniff\n\
Header always set X-XSS-Protection "1; mode=block"\n\
Header always set X-Robots-Tag none\n\
Header always set X-Frame-Options SAMEORIGIN\n\
</IfModule>\n\
\n\
SetEnv APP_ENV development\n\
SetEnv APP_DIR /var/www/html/monarc\n\
</VirtualHost>' > /etc/apache2/sites-available/000-default.conf

# Allow Apache override to all
RUN sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf

# Create necessary directories
RUN mkdir -p /var/www/html/monarc/data/cache \
/var/www/html/monarc/data/LazyServices/Proxy \
/var/www/html/monarc/data/DoctrineORMModule/Proxy \
/var/www/html/monarc/data/import/files

# Copy entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

EXPOSE 80

ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["apachectl", "-D", "FOREGROUND"]
38 changes: 38 additions & 0 deletions Dockerfile.stats
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive
ENV LANGUAGE=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
ENV FLASK_APP=runserver.py
ENV STATS_CONFIG=production.py

# Install dependencies
RUN apt-get update && \
apt-get install -y \
git \
curl \
python3 \
python3-pip \
python3-venv \
nodejs \
npm \
postgresql-client \
locales && \
locale-gen en_US.UTF-8 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 - && \
ln -s /root/.local/bin/poetry /usr/local/bin/poetry

WORKDIR /var/www/stats-service

# Copy entrypoint script
COPY docker-stats-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-stats-entrypoint.sh

EXPOSE 5005

ENTRYPOINT ["docker-stats-entrypoint.sh"]
Loading
Loading