-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add base docker configs #1
Open
akiszka-yf
wants to merge
13
commits into
YetiForceCompany:main
Choose a base branch
from
akiszka-yf:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
537d4b2
Add base docker configs
akiszka-yf f501ad2
Remove old submodule
akiszka-yf abaa2bf
Make entrypoint compliant with best practice
akiszka-yf d150b8b
Pin composer version
akiszka-yf 419b517
Verify all downloads
akiszka-yf e0ffe9a
Add explanation to cron-runner.sh
akiszka-yf a9da462
Add labels
akiszka-yf c58270b
Start move to nginx
akiszka-yf 24c1b26
Prod settings and cron
akiszka-yf 79c2ad2
Update cron mounts
akiszka-yf 18dd1f4
Add prod and dev modes
akiszka-yf 9f71daa
Set retry limit in cron
akiszka-yf e517cf3
Add Docker test runner
akiszka-yf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
MARIADB_ROOT_PASSWORD=example | ||
MARIADB_DATABASE=yetiforce | ||
MARIADB_USER=yeti | ||
MARIADB_PASSWORD=yeti | ||
HOSTNAME=yeti | ||
TLS_EMAIL=internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "YetiForceCRM"] | ||
path = YetiForceCRM | ||
url = [email protected]:YetiForceCompany/YetiForceCRM.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,49 @@ | ||
# docker | ||
# YetiForceCRM Docker | ||
|
||
Official YetiForce Docker image | ||
|
||
## Instructions | ||
|
||
### Production | ||
|
||
To start YetiForce in a production configuration: | ||
1. In the `.env` file set the `HOSTNAME` to the where you will be running YetiForce and set `TLS_EMAIL` to your email address. Those settings will make sure that your website has a proper TLS certificate. | ||
2. Download the YetiForce code: `git submodule update --init`. | ||
3. Run `docker compose up -d`. | ||
4. Go to `https://HOSTNAME` and go through the installation process. For your database settings, enter: | ||
- Address: db | ||
- Port: 3306 | ||
- Username: yeti | ||
- Password: yeti | ||
- Database name: yetiforce | ||
|
||
### Development | ||
|
||
This image can also work in development mode. This mode is designed for actively making changes in YF itself. As such, it includes the following changes: | ||
- YetiForce is run from the `./YetiForceCRM` directory | ||
- MariaDB is available on `localhost:3306` | ||
- PHP has a development configuration | ||
|
||
This means that you will be able to make changes in `./YetiForceCRM`, see them reflected in your browser, and commit them normally. | ||
|
||
To run in this mode: | ||
1. Add a line with `127.0.0.1 yeti` to `/etc/hosts` on Unix or `C:\Windows\System32\drivers\etc\hosts` on Windows. | ||
2. Download the YetiForce code: `git submodule update --init`. | ||
3. Install YetiForce dependencies: | ||
```shell | ||
cd ./YetiForceCRM | ||
install -m755 -d YetiForceCRM/config/Modules | ||
yarn install --modules-folder "./public_html/libraries" --ignore-optional --production=true | ||
cd public_html/src | ||
yarn install --ignore-optional --production=true | ||
cd ../.. | ||
composer --no-interaction install --no-dev | ||
cd .. | ||
``` | ||
4. Start the server with `docker compose -f docker-compose.yaml -f docker-compose.dev.yaml up -d` | ||
4. Go to `https://HOSTNAME` and go through the installation process. For your database settings, enter: | ||
- Address: db | ||
- Port: 3306 | ||
- Username: yeti | ||
- Password: yeti | ||
- Database name: yetiforce |
Submodule YetiForceCRM
added at
692109
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
auto_https disable_redirects | ||
} | ||
|
||
{$HOSTNAME}:443 { | ||
tls {$TLS_EMAIL} | ||
reverse_proxy nginx:80 | ||
} | ||
|
||
{$HOSTNAME}:80 { | ||
reverse_proxy nginx:80 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM alpine:3.17 | ||
COPY ./cron-runner.sh /usr/local/bin/cron-runner.sh | ||
RUN apk add --no-cache bash \ | ||
&& chmod +x /usr/local/bin/cron-runner.sh | ||
|
||
CMD ["/usr/local/bin/cron-runner.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
|
||
while true | ||
do | ||
if test -f "/var/www/html/config/Main.php"; then | ||
unique_key=$(grep application_unique_key /var/www/html/config/Main.php | awk -F"'" '{print $2}') | ||
wget --timeout=900 -qO- http://nginx/cron.php?app_key="${unique_key}" | ||
fi | ||
|
||
sleep 60 | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: yetiforce-dev | ||
version: '3' | ||
services: | ||
db: | ||
ports: | ||
- 3306:3306 | ||
php: | ||
build: | ||
target: php-dev | ||
volumes: | ||
- type: bind | ||
source: ./YetiForceCRM | ||
target: /var/www/html | ||
|
||
volumes: | ||
crm_data: null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: yetiforce | ||
version: '3' | ||
services: | ||
caddy: | ||
hostname: ${HOSTNAME} | ||
image: caddy:2.6 | ||
depends_on: | ||
- nginx | ||
env_file: | ||
- .env | ||
restart: on-failure | ||
ports: | ||
- "80:80" | ||
- "443:443" | ||
- "443:443/udp" | ||
volumes: | ||
- ./caddy/Caddyfile:/etc/caddy/Caddyfile | ||
- caddy_data:/data | ||
- caddy_config:/config | ||
db: | ||
build: | ||
context: . | ||
dockerfile: ./mariadb/Dockerfile | ||
env_file: | ||
- .env | ||
restart: on-failure | ||
volumes: | ||
- type: volume | ||
source: db_data | ||
target: /var/lib/mysql | ||
php: | ||
build: | ||
context: . | ||
dockerfile: ./php/Dockerfile | ||
target: php-prod | ||
restart: on-failure | ||
volumes: | ||
- type: volume | ||
source: crm_data | ||
target: /var/www/html | ||
nginx: | ||
build: | ||
context: . | ||
dockerfile: ./nginx/Dockerfile | ||
target: nginx | ||
depends_on: | ||
- php | ||
restart: on-failure | ||
volumes_from: | ||
- php:rw | ||
cron: | ||
build: | ||
context: ./cron | ||
deploy: | ||
restart_policy: | ||
condition: on-failure | ||
delay: 60s | ||
volumes_from: | ||
- php:ro | ||
depends_on: | ||
- nginx | ||
|
||
volumes: | ||
crm_data: | ||
db_data: | ||
caddy_data: | ||
caddy_config: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[mariadb] | ||
innodb_lock_wait_timeout = 600 | ||
table_definition_cache = 2400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM mariadb:lts | ||
COPY ./mariadb/99-docker-overlay.cnf /etc/mysql/conf.d | ||
RUN chmod 444 /etc/mysql/conf.d/99-docker-overlay.cnf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM nginx:stable AS nginx | ||
|
||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
||
RUN apt-get update && \ | ||
apt-get install --no-install-recommends -y \ | ||
nginx-extras \ | ||
&& apt-get clean \ | ||
&& rm -rf /etc/nginx/conf.d/* /etc/nginx/sites-enabled/* /var/lib/apt/lists/* | ||
|
||
COPY ./YetiForceCRM/tests/setup/nginx/yetiforce.conf /etc/nginx/yetiforce.conf | ||
COPY ./nginx/docker.conf /etc/nginx/conf.d/default.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
############################################## | ||
# Best configuration for YetiForceCRM # | ||
# Created by [email protected] # | ||
# Modified to work with Docker # | ||
############################################## | ||
# HTTP | ||
server { | ||
listen 80 default_server; | ||
server_name localhost; | ||
root /var/www/html/public_html; | ||
index index.php index.html; | ||
#return 301 https://$server_name$request_uri; | ||
|
||
## Configuration for YetiForceCRM | ||
include /etc/nginx/yetiforce.conf; | ||
|
||
## Logs | ||
error_log /var/log/nginx/localhost_error.log warn; | ||
access_log /var/log/nginx/localhost_access.log; | ||
|
||
########################## | ||
## SabreDAV ## | ||
########################## | ||
rewrite ^/.well-known/caldav /dav.php redirect; | ||
rewrite ^/.well-known/carddav /dav.php redirect; | ||
|
||
location ~ ^(.+\.php)(.*)$ { | ||
try_files $fastcgi_script_name = 404; | ||
include /etc/nginx/fastcgi_params; | ||
fastcgi_split_path_info ^(.+\.php)(.*)$; | ||
fastcgi_pass php:9000; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
fastcgi_param PATH_INFO $fastcgi_path_info; | ||
fastcgi_send_timeout 600; | ||
fastcgi_read_timeout 600; | ||
keepalive_timeout 600; | ||
proxy_connect_timeout 600; | ||
proxy_send_timeout 600; | ||
proxy_read_timeout 600; | ||
} | ||
|
||
########################## | ||
## PHP ## | ||
########################## | ||
location ~ \.php$ { | ||
try_files $uri =404; | ||
include /etc/nginx/fastcgi_params; | ||
fastcgi_split_path_info ^(.+\.php)(/.+)$; | ||
fastcgi_pass php:9000; | ||
fastcgi_index index.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
fastcgi_param PATH_INFO $fastcgi_path_info; | ||
fastcgi_send_timeout 600; | ||
fastcgi_read_timeout 600; | ||
keepalive_timeout 600; | ||
proxy_connect_timeout 600; | ||
proxy_send_timeout 600; | ||
proxy_read_timeout 600; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
FROM php:8.0-fpm AS php-base | ||
|
||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
||
RUN apt-get update && apt-get install --no-install-recommends -y \ | ||
imagemagick \ | ||
libc-client-dev \ | ||
libcurl4-openssl-dev \ | ||
libkrb5-dev \ | ||
libldap-dev \ | ||
libmagickwand-dev \ | ||
libpng-dev \ | ||
libxml2-dev \ | ||
libzip-dev \ | ||
unixodbc-dev \ | ||
zlib1g-dev \ | ||
&& docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ | ||
&& docker-php-ext-install -j8 imap pdo_mysql curl gd xml zip soap iconv intl bcmath sockets exif ldap opcache \ | ||
&& apt-get clean \ | ||
&& printf "\n" | pecl install imagick \ | ||
&& docker-php-ext-enable imagick \ | ||
&& printf "\n" | pecl install apcu \ | ||
&& docker-php-ext-enable apcu \ | ||
&& pecl install pdo_sqlsrv \ | ||
&& docker-php-ext-enable pdo_sqlsrv \ | ||
&& pecl cache-clear \ | ||
&& rm -rf /tmp/pear | ||
|
||
FROM node:18-alpine AS build-yarn | ||
|
||
RUN apk add --no-cache git | ||
|
||
COPY ./YetiForceCRM /opt/YetiForceCRM | ||
WORKDIR /opt/YetiForceCRM | ||
RUN --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn rm .git && yarn install --modules-folder "./public_html/libraries" --ignore-optional --production=true | ||
WORKDIR /opt/YetiForceCRM/public_html/src | ||
RUN --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn yarn install --ignore-optional --production=true | ||
|
||
|
||
FROM php-base AS build-composer | ||
|
||
RUN php -r "copy('https://raw.githubusercontent.com/composer/getcomposer.org/70527179915d55b3811bebaec55926afd331091b/web/installer', 'composer-setup.php');" \ | ||
&& php -r "if (hash_file('sha384', 'composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \ | ||
&& php composer-setup.php \ | ||
&& php -r "unlink('composer-setup.php');" \ | ||
&& mv composer.phar /usr/local/bin/composer | ||
|
||
COPY --from=build-yarn /opt/YetiForceCRM /opt/YetiForceCRM | ||
WORKDIR /opt/YetiForceCRM | ||
RUN --mount=type=cache,target=/root/.composer/cache composer --no-interaction install --no-dev | ||
|
||
FROM php-base AS php-prod | ||
|
||
RUN cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" | ||
COPY ./YetiForceCRM/tests/setup/php/prod.ini /usr/local/etc/php/conf.d | ||
COPY ./php/docker-config.ini /usr/local/etc/php/conf.d | ||
COPY ./php/fpm.conf /usr/local/etc/php-fpm.d/zzz-docker.conf | ||
|
||
WORKDIR /var/www/html | ||
COPY --from=build-composer --chown=www-data:www-data --chmod=644 /opt/YetiForceCRM/ /var/www/html | ||
RUN install -owww-data -gwww-data -m755 -d config/Modules && find . -type d -exec chown www-data:www-data -- {} \+ && find . -type d -exec chmod 755 -- {} \+ | ||
|
||
FROM php-base AS php-dev | ||
|
||
RUN cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" | ||
COPY ./YetiForceCRM/tests/setup/php/dev.ini /usr/local/etc/php/conf.d | ||
COPY ./php/docker-config.ini /usr/local/etc/php/conf.d | ||
COPY ./php/fpm.conf /usr/local/etc/php-fpm.d/zzz-docker.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
session.cookie_samesite="Strict" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[www] | ||
|
||
env[PROVIDER] = docker | ||
php_admin_value[error_log] = /var/log/php/fpm_yfprod_error.log | ||
php_admin_value[open_basedir] = /var/www/html/:/tmp/:/var/tmp/:/etc/nginx/ssl/:/etc/ssl/:/usr/bin/gpg:/usr/bin/gpg-agent:/usr/bin/gpgconf | ||
clear_env = no | ||
request_terminate_timeout = 600 | ||
pm.process_idle_timeout = 600s; | ||
pm.max_requests = 5000 | ||
catch_workers_output = yes |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?