Skip to content
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

Feat docker #258

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.github
.gitignore
docker-compose.yml
Dockerfile
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
HTTP_PORT=8881
DB_PORT=3307
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ config/database.php
config/captcha.php
config/env.php
tarsius

.env
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM php:8.3.13-apache

RUN apt-get update \
&& apt-get install -y libicu-dev libxml2-dev libzip-dev libpng-dev libonig-dev libjpeg62-turbo libjpeg62-turbo-dev libfreetype6-dev \
&& docker-php-ext-install intl xml xmlwriter gettext mbstring zip mysqli pdo_mysql \
&& docker-php-ext-enable intl xml xmlwriter gettext mbstring zip mysqli pdo_mysql \
&& docker-php-ext-install -j$(nproc) iconv \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-enable gd

RUN a2enmod rewrite

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

WORKDIR /var/www/html

COPY . /var/www/html

RUN composer install

RUN chown -R www-data:www-data /var/www/html/files
RUN chown -R www-data:www-data /var/www/html/images
RUN chown -R www-data:www-data /var/www/html/repository

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

EXPOSE 80

ENTRYPOINT ["/entrypoint.sh"]

CMD ["apache2-foreground"]

14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,17 @@ to learn more about GPL.
- PHP GD enabled
- PHP gettext enabled
- PHP mbstring enabled

### Running Docker Development

Using docker for running requires Docker Desktop service, as it will use Docker to create the database.
Before run docker compose copy .env.example to .env for setting http port and maria db (db) port
can be change on .env

You can run the test using this command :

```shell
docker compose up -d --build
```

Setting docker default can be change on docker-compose.yml
49 changes: 49 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: "3"

services:
slims:
container_name: slims
build:
context: .
dockerfile: Dockerfile
environment:
- ENV=production
- DB_HOST=db
- DB_PORT=3306
- DB_USER=root
- DB_PASS=Pass123
- DB_NAME=senayan
volumes:
- appfiles:/var/www/html/files
- appimages:/var/www/html/images
- apprepo:/var/www/html/repository
ports:
- "${HTTP_PORT}:80"
networks:
- proxy
depends_on:
- db

db:
image: mariadb:lts
container_name: db
ports:
- "${DB_PORT}:3306"
volumes:
- ./install/senayan_ddl.sql:/docker-entrypoint-initdb.d/init.sql
- dbdata:/var/lib/mysql
environment:
- MARIADB_ROOT_PASSWORD=Pass123
- MARIADB_DATABASE=senayan
networks:
- proxy

networks:
proxy:
driver: bridge

volumes:
dbdata:
appfiles:
appimages:
apprepo:
47 changes: 47 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh

# Write environment variables to env.php
cat <<EOF >/var/www/html/config/env.php
<?php
\$env = "${ENV}";
\$conditional_environment = "${ENV}";
\$based_on_ip = false;
\$range_ip = [''];
if (\$based_on_ip) {
if (array_key_exists('HTTP_X_FORWARDED_FOR', \$_SERVER) && in_array(\$_SERVER['HTTP_X_FORWARDED_FOR'], \$range_ip)) {
\$env = \$conditional_environment;
} else if (in_array(\$_SERVER['REMOTE_ADDR'], \$range_ip)) {
\$env = \$conditional_environment;
}
}
EOF

echo "PHP configuration file created: /var/www/html/config/env.php"
cat /var/www/html/config/env.php

# Write environment variables to database.php
cat <<EOF >/var/www/html/config/database.php
<?php
return [
'default_profile' => 'SLiMS',
'proxy' => false,
'nodes' => [
'SLiMS' => [
'host' => '${DB_HOST}',
'database' => '${DB_NAME}',
'port' => '${DB_PORT}',
'username' => '${DB_USER}',
'password' => '${DB_PASS}',
'options' => [
'storage_engine' => 'MyISAM'
]
]
]
];
EOF

echo "PHP configuration file created: /var/www/html/config/database.php"
cat /var/www/html/config/database.php

# Start the PHP application
exec "$@"
2,122 changes: 2,122 additions & 0 deletions install/senayan_ddl.sql

Large diffs are not rendered by default.