Skip to content

Commit

Permalink
新增环境变量支持
Browse files Browse the repository at this point in the history
  • Loading branch information
AkarinLiu committed Apr 1, 2024
1 parent 126dc4c commit 8723f04
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@ COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
RUN composer create-project flarum/flarum /flarum
EXPOSE 80
COPY config.php /config.php
ENV FLARUM_DB_HOST=mysql
ENV FLARUM_DB_DATABASE=flarum
ENV FLARUM_DB_USERNAME=flarum
ENV FLARUM_DB_PASSWORD=flarum
ENV FLARUM_DB_PREFIX=flarum_
ENV FLARUM_URL=http://localhost
ENTRYPOINT bash /docker-entrypoint.sh
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ services:
runtime:
image: ghcr.io/akarinliu/flarum:latest
restart: always
environmnet:
- FLARUM_DB_HOST=mysql
- FLARUM_DB_NAME=flarum
- FLARUM_DB_USER=flarum
- FLARUM_DB_PASSWORD=flarum
volumes:
- ./data:/var/www/html
ports:
Expand Down
29 changes: 29 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php return array (
'debug' => false,
'database' =>
array (
'driver' => 'mysql',
'host' => 'flarum_db_host',
'port' => 3306,
'database' => 'flarum_db_name',
'username' => 'flarum_db_user',
'password' => 'flarum_db_password',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => 'flarum_db_prefix',
'strict' => false,
'engine' => 'InnoDB',
'prefix_indexes' => true,
),
'url' => 'flarum_url',
'paths' =>
array (
'api' => 'api',
'admin' => 'admin',
),
'headers' =>
array (
'poweredByHeader' => true,
'referrerPolicy' => 'same-origin',
),
);
9 changes: 9 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,14 @@ if [ ! -e "/var/www/html/site.php" ]; then
chown -R www-data:www-data /var/www/html
chmod -R 755 /var/www/html
fi
if [ ! -e "/var/www/html/config.php" ]; then
cp -r /config.php /var/www/html/
sed -i "s/flarum_db_host/${FLARUM_DB_HOST}/g" /var/www/html/config.php
sed -i "s/flarum_db_name/${FLARUM_DB_NAME}/g" /var/www/html/config.php
sed -i "s/flarum_db_user/${FLARUM_DB_USER}/g" /var/www/html/config.php
sed -i "s/flarum_db_password/${FLARUM_DB_PASSWORD}/g" /var/www/html/config.php
sed -i "s/flarum_db_prefix/${FLARUM_DB_PREFIX}/g" /var/www/html/config.php
sed -i "s/flarum_url/${FLARUM_URL}/g" /var/www/html/config.php
fi
echo "Starting Flarum..."
httpd -D FOREGROUND

0 comments on commit 8723f04

Please sign in to comment.