Skip to content

Commit

Permalink
fix. replace readme
Browse files Browse the repository at this point in the history
  • Loading branch information
HalcyonAzure committed Apr 21, 2023
1 parent 93a3b89 commit cca7e6f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 15 deletions.
2 changes: 1 addition & 1 deletion 000-default.conf.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<VirtualHost *:${APACHE_PORT}>
<VirtualHost *:${WEB_PORT}>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
Expand Down
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ FROM php:8.1-apache
# 安装相关拓展
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN a2enmod rewrite && chmod +x /usr/local/bin/install-php-extensions && \
RUN apt-get update && \
apt-get install -y gettext && \
apt-get clean && rm -rf /var/cache/apt/* && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* && \
a2enmod rewrite && chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions imagick bcmath pdo_mysql pdo_pgsql redis && \
\
{ \
Expand All @@ -30,17 +33,13 @@ RUN a2enmod rewrite && chmod +x /usr/local/bin/install-php-extensions && \
chown -R www-data:root /var/www; \
chmod -R g=u /var/www

RUN apt-get update && \
apt-get install -y gettext && \
rm -rf /var/lib/apt/lists/*

COPY ./ /var/www/lsky/
COPY ./000-default.conf.template /etc/apache2/sites-enabled/
COPY ./ports.conf.template /etc/apache2/
COPY entrypoint.sh /
WORKDIR /var/www/html/
VOLUME /var/www/html
EXPOSE 80
ENV WEB_PORT 8089
RUN chmod a+x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apachectl","-D","FOREGROUND"]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ docker run -d \
--restart unless-stopped \
-p 9080:80 \
-v /path-to-data:/var/www/html \
-e WEB_PORT=8089 \
halcyonazure/lsky-pro-docker:latest
```

## 环境变量

目前该容器只有一个环境变量:`WEB_PORT`,用于指定容器内的`Apache`监听的端口,默认为`8089`,如果需要修改的话可以在启动容器时添加`-e WEB_PORT=8089`来指定端口

### Windows内以`WSL`的方式部署`Docker`容器

按照 [#13](https://github.com/HalcyonAzure/lsky-pro-docker/issues/13) 的反馈来看,如果在`Windows`内创建容器出现了将文件挂载于`WSL`内,然后出现了重启系统文件未识别的情况,可以将映射目录修改为类似`\\wsl$\Ubuntu\path-mount-lsky\`的形式
Expand All @@ -39,6 +44,8 @@ services:
restart: unless-stopped
hostname: lskypro
container_name: lskypro
environment:
- WEB_PORT=8089
volumes:
- /data/lsky/web:/var/www/html/
ports:
Expand Down
33 changes: 28 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
version: '3'
services:
lskypro:
build: .
image: lsky-pro-docker:test
image: halcyonazure/lsky-pro-docker:latest
restart: unless-stopped
hostname: lskypro
container_name: lskypro
environment:
- WEB_PORT=8089
volumes:
- /data/lsky/web:/var/www/html/
environment:
- APACHE_PORT=8876
ports:
- "9080:8876"
- "9080:8089"
networks:
- lsky-net

mysql-lsky:
image: mysql:5.7.22
restart: unless-stopped
# 主机名,可作为"数据库连接地址"
hostname: mysql-lsky
# 容器名称
container_name: mysql-lsky
# 修改加密规则
command: --default-authentication-plugin=mysql_native_password
volumes:
- /data/lsky/mysql/data:/var/lib/mysql
- /data/lsky/mysql/conf:/etc/mysql
- /data/lsky/mysql/log:/var/log/mysql
environment:
MYSQL_ROOT_PASSWORD: lAsWjb6rzSzENUYg # 数据库root用户密码,自行修改
MYSQL_DATABASE: lsky-data # 可作为"数据库名称/路径"
networks:
- lsky-net

networks:
lsky-net: {}
6 changes: 4 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash
set -eu

envsubst '${APACHE_PORT}' < /etc/apache2/sites-enabled/000-default.conf.template > /etc/apache2/sites-enabled/000-default.conf
envsubst '${APACHE_PORT}' < /etc/apache2/ports.conf.template > /etc/apache2/ports.conf
WEB_PORT = ${WEB_PORT:-8089}

envsubst '${WEB_PORT}' < /etc/apache2/sites-enabled/000-default.conf.template > /etc/apache2/sites-enabled/000-default.conf
envsubst '${WEB_PORT}' < /etc/apache2/ports.conf.template > /etc/apache2/ports.conf

if [ ! -e '/var/www/html/public/index.php' ]; then
cp -a /var/www/lsky/* /var/www/html/
Expand Down
2 changes: 1 addition & 1 deletion ports.conf.template
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Listen ${APACHE_PORT}
Listen ${WEB_PORT}

0 comments on commit cca7e6f

Please sign in to comment.