Skip to content

Commit

Permalink
feat: nacos support application.properties
Browse files Browse the repository at this point in the history
  • Loading branch information
WGrape committed Apr 9, 2024
1 parent 724cbfc commit 442abbf
Show file tree
Hide file tree
Showing 17 changed files with 163 additions and 0 deletions.
13 changes: 13 additions & 0 deletions azkaban/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### azkaban ############################################

# -------------- image config ---------------
# official image
IMAGE_OFFICIAL_AZKABAN_NAME=test/test
IMAGE_OFFICIAL_AZKABAN_VERSION=4.0.0
# basic image
IMAGE_BASIC_AZKABAN_VERSION=4.0.0
# app image
IMAGE_APP_AZKABAN_VERSION=latest
# -------------- service config --------------
AZKABAN_HOST_PORT=4500
AZKABAN_CONTAINER_PORT=4500
40 changes: 40 additions & 0 deletions azkaban/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## What is this directory
This is the service directory, it includes these directories and files as bellow.

## 1. Directories

### (1) Commit to Git.

#### /hooks

```/hooks```: This is the hook actions while the service/container start/stop.

#### /init

```/init```: This is init scripts after the container created, is executed by ```./hooks/after_start.sh```

#### /make_app_image
```/make_app_image```: This is the ```sparrow-app-*``` image making directory.

#### /make_basic_image
```/make_basic_image```: This is the ```sparrow-basic-*``` image making directory.

#### /templates
```/templates```: this is the template directory for the service, the ```template``` means all static and unchanging files.

### (2)Not commit to Git.

#### /data
```data```: This is the data storage directory for the service/container, you mustn't create any files in the ```data``` directory, because it may cause service/container start failed.

#### /logs
- ```logs```: This is the log storage directory for the service/container.

## 2. Files

#### /.env
```/.env```: this is the environment variables file.

#### /docker-compose.yml
```/docker-compose.yml```: this is the ```docker-compose.yml``` file.

22 changes: 22 additions & 0 deletions azkaban/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
### azkaban #########################################################
azkaban:
hostname: azkaban
image: sparrow-app-azkaban:${IMAGE_APP_AZKABAN_VERSION} # pull_or_build_app_image(local image=>remote image=>build image)
container_name: sparrow_container_${CONTAINER_NAMESPACE}_azkaban
platform: ${FROM_PLATFORM}
restart: always
environment:
TZ: ${TZ}
LANG: C.UTF-8
volumes:
- /etc/localtime:/etc/localtime:ro
- ./azkaban/:/home/sparrow/azkaban/
- ./azkaban/data/:/var/data/azkaban/ # data persistence, use a common data persistence directory /var/data/{SERVICE}
ports:
# You don't need to expose the port in the Dockerfile.
- "${AZKABAN_HOST_PORT}:${AZKABAN_CONTAINER_PORT}"
networks:
- backend
# only for debug
# command: "tail -f /dev/null"
2 changes: 2 additions & 0 deletions azkaban/hooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## What is this directory
This is the hook actions while the service/container start/stop.
4 changes: 4 additions & 0 deletions azkaban/hooks/after_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# include sdk of sparrow.
. .work/include/sdk.sh
4 changes: 4 additions & 0 deletions azkaban/hooks/after_stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# include sdk of sparrow.
. .work/include/sdk.sh
4 changes: 4 additions & 0 deletions azkaban/hooks/before_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# include sdk of sparrow.
. .work/include/sdk.sh
4 changes: 4 additions & 0 deletions azkaban/hooks/before_stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# include sdk of sparrow.
. .work/include/sdk.sh
2 changes: 2 additions & 0 deletions azkaban/init/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## What is this directory
This is init scripts after the container created, is executed by ```./hooks/after_start.sh```.
3 changes: 3 additions & 0 deletions azkaban/make_app_image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ARG FROM_PLATFORM
ARG IMAGE_BASIC_AZKABAN_VERSION
FROM --platform=${FROM_PLATFORM} sparrow-basic-azkaban:${IMAGE_BASIC_AZKABAN_VERSION}
2 changes: 2 additions & 0 deletions azkaban/make_app_image/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## What is this directory
This is the ```sparrow-app-*``` image making directory.
31 changes: 31 additions & 0 deletions azkaban/make_app_image/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

# cd base dir of project.
# the process is in the same shell as the starting shell.
cd $SPARROW_BASE_PATH

# define this service.
service_name="azkaban"

print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_AZKABAN_VERSION"
if pull basic $service_name $IMAGE_BASIC_AZKABAN_VERSION; then
print_info "pull success"
elif . "./${service_name}/make_basic_image/run.sh"; then
print_info "build success"
else
print_error "pull/build failed"
exit 1
fi

cd $service_name/
if ! docker build \
--build-arg FROM_PLATFORM=${FROM_PLATFORM} \
--build-arg IMAGE_BASIC_AZKABAN_VERSION=${IMAGE_BASIC_AZKABAN_VERSION} \
\
-f ./make_app_image/Dockerfile \
-t sparrow-app-$service_name:${IMAGE_APP_AZKABAN_VERSION} . ; then
print_error "build image failed"
exit 1
fi

cd ../
4 changes: 4 additions & 0 deletions azkaban/make_basic_image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ARG FROM_PLATFORM
ARG IMAGE_OFFICIAL_AZKABAN_NAME
ARG IMAGE_OFFICIAL_AZKABAN_VERSION
FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_AZKABAN_NAME}:${IMAGE_OFFICIAL_AZKABAN_VERSION} AS builder
2 changes: 2 additions & 0 deletions azkaban/make_basic_image/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## What is this directory
This is the ```sparrow-basic-*``` image making directory.
22 changes: 22 additions & 0 deletions azkaban/make_basic_image/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# cd base dir of project.
# the process is in the same shell as the starting shell.
cd $SPARROW_BASE_PATH

# define this service.
service_name="azkaban"

cd $service_name/
if ! docker build \
--build-arg FROM_PLATFORM=${FROM_PLATFORM} \
--build-arg IMAGE_OFFICIAL_AZKABAN_NAME=${IMAGE_OFFICIAL_AZKABAN_NAME} \
--build-arg IMAGE_OFFICIAL_AZKABAN_VERSION=${IMAGE_OFFICIAL_AZKABAN_VERSION} \
\
-f ./make_basic_image/Dockerfile \
-t sparrow-basic-$service_name:${IMAGE_BASIC_AZKABAN_VERSION} . ; then
print_error "build image failed"
exit 1
fi

cd ../
3 changes: 3 additions & 0 deletions azkaban/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## What is this directory
This is the template directory for the service, the ```template``` means all static and unchanging files.

1 change: 1 addition & 0 deletions nacos/templates/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ nacos.naming.data.warmup=true
nacos.console.ui.enabled=true
nacos.core.param.check.enabled=true

# enable token cache: https://nacos.io/zh-cn/docs/v2/guide/user/auth.html
nacos.core.auth.plugin.nacos.token.cache.enable=true

0 comments on commit 442abbf

Please sign in to comment.