Skip to content

Commit

Permalink
Merge pull request #77 from Simple4H/feature/docker-support
Browse files Browse the repository at this point in the history
feat(all): docker support
  • Loading branch information
Simple4H committed Mar 15, 2024
2 parents d6b0776 + 2d8f23f commit 5bf9c89
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: "3.8"
services:
nacos:
image: nacos/nacos-server:v2.3.1
container_name: nacos-standalone-mysql
env_file:
- ./docker/config/nacos-standalone-mysql.env
volumes:
- ./log/nacos-logs/:/home/nacos/logs
ports:
- "8848:8848"
- "9848:9848"
depends_on:
mysql:
condition: service_healthy
restart: always
mysql:
container_name: mysql
build:
context: .
dockerfile: ./docker/image/Dockerfile-MySQL
image: simple4h/mysql:8.0.30
env_file:
- ./docker/config/mysql.env
volumes:
- ./log/mysql-logs:/var/lib/mysql
ports:
- "3306:3306"
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
interval: 5s
timeout: 10s
retries: 10
5 changes: 5 additions & 0 deletions docker/config/mysql.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=nacos_database
MYSQL_USER=nacos
MYSQL_PASSWORD=nacos
LANG=C.UTF-8
12 changes: 12 additions & 0 deletions docker/config/nacos-standalone-mysql.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PREFER_HOST_MODE=hostname
MODE=standalone
SPRING_DATASOURCE_PLATFORM=mysql
MYSQL_SERVICE_HOST=mysql
MYSQL_SERVICE_DB_NAME=nacos_database
MYSQL_SERVICE_PORT=3306
MYSQL_SERVICE_USER=nacos
MYSQL_SERVICE_PASSWORD=nacos
MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
NACOS_AUTH_IDENTITY_KEY=2222
NACOS_AUTH_IDENTITY_VALUE=2xxx
NACOS_AUTH_TOKEN=SecretKey012345678901234567890123456789012345678901234567890123456789
5 changes: 5 additions & 0 deletions docker/image/Dockerfile-MySQL
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM mysql:8.0.31
ADD https://raw.githubusercontent.com/alibaba/nacos/develop/distribution/conf/mysql-schema.sql /docker-entrypoint-initdb.d/nacos-mysql.sql
RUN chown -R mysql:mysql /docker-entrypoint-initdb.d/nacos-mysql.sql
EXPOSE 3306
CMD ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]

0 comments on commit 5bf9c89

Please sign in to comment.