Nacos 2.x/3.x の瀚高データベース対応
1. pom.xmlの修正
ルートディレクトリのnacos-all => pom.xml
<dependencyManagement>
<dependency>
<groupId>com.highgo</groupId>
<artifactId>HgdbJdbc</artifactId>
<version>6.2.3</version>
</dependency>
</dependencyManagement>
nacos-configモジュール => pom.xml
<dependency>
<groupId>com.highgo</groupId>
<artifactId>HgdbJdbc</artifactId>
</dependency>
2. nacos-configモジュールの接続ドライバーを変更 ExternalDataSourceProperties
com.alibaba.nacos.persistence.datasource.ExternalDataSourceProperties
private static final String JDBC_DRIVER_NAME = "com.mysql.cj.jdbc.Driver";
変更後:
private static final String JDBC_DRIVER_NAME = "com.highgo.jdbc.Driver";
3. nacos-datasource-pluginモジュールにサポートするデータベースタイプを追加
com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant
public class DataSourceConstant {
public static final String MYSQL = "mysql";
public static final String DERBY = "derby";
public static final String HIGHGO = "highgo";
}
4. SPIメカニズムによるコード拡張
以下のクラスを作成:
- ConfigurationAggregateMapperByHighgo
- ConfigurationBetaMapperByHighgo
- ConfigurationInfoMapperByHighgo
- ConfigurationInfoTagMapperByHighgo
- ConfigurationTagsRelationshipMapperByHighgo
- GroupQuotaMapperByHighgo
- HistoricalConfigurationInfoMapperByHighgo
- TenantQuotaMapperByHighgo
- TenantInfoMapperByHighgo
/*
* Copyright 1999-2022 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.plugin.datasource.impl.highgo;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
import com.alibaba.nacos.plugin.datasource.constants.FieldConstant;
import com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper;
import com.alibaba.nacos.plugin.datasource.mapper.ConfigInfoAggrMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;
import java.util.List;
/**
* Configuration aggregation mapper implementation for Highgo database.
*
* @Date: 2023/05/11
*/
public class ConfigurationAggregateMapperByHighgo extends AbstractMapper implements ConfigInfoAggrMapper {
@Override
public MapperResult findConfigInfoAggrByPageFetchRows(MapperContext context) {
int offsetRow = context.getStartRow();
int fetchSize = context.getPageSize();
String configId = (String) context.getWhereParameter(FieldConstant.DATA_ID);
String groupId = (String) context.getWhereParameter(FieldConstant.GROUP_ID);
String namespaceId = (String) context.getWhereParameter(FieldConstant.TENANT_ID);
String querySql =
"SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE data_id= ? AND "
+ " group_id= ? AND tenant_id= ? ORDER BY datum_id " + " OFFSET " + offsetRow + " LIMIT " + fetchSize;
List<Object> parameterList = CollectionUtils.list(configId, groupId, namespaceId);
return new MapperResult(querySql, parameterList);
}
@Override
public String getDataSource() {
return DataSourceConstant.HIGHGO;
}
}
/*
* Copyright 1999-2022 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.plugin.datasource.impl.highgo;
import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
import com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper;
import com.alibaba.nacos.plugin.datasource.mapper.ConfigInfoBetaMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;
import java.util.ArrayList;
import java.util.List;
/**
* Configuration beta mapper implementation for Highgo database.
*
* @Date: 2023/05/11
*/
public class ConfigurationBetaMapperByHighgo extends AbstractMapper implements ConfigInfoBetaMapper {
@Override
public MapperResult findAllConfigInfoBetaForDumpAllFetchRows(MapperContext context) {
int offsetValue = context.getStartRow();
int limitValue = context.getPageSize();
String queryStatement = " SELECT t.id,data_id,group_id,tenant_id,app_name,content,md5,gmt_modified,beta_ips,encrypted_data_key "
+ " FROM ( SELECT id FROM config_info_beta ORDER BY id OFFSET " + offsetValue + " LIMIT " + limitValue + ")"
+ " g, config_info_beta t WHERE g.id = t.id ";
List<Object> parameters = new ArrayList<>();
parameters.add(offsetValue);
parameters.add(limitValue);
return new MapperResult(queryStatement, parameters);
}
@Override
public String getDataSource() {
return DataSourceConstant.HIGHGO;
}
}
/*
* Copyright 1999-2022 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.plugin.datasource.impl.highgo;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.common.utils.NamespaceUtil;
import com.alibaba.nacos.plugin.datasource.constants.ContextConstant;
import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
import com.alibaba.nacos.plugin.datasource.constants.FieldConstant;
import com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper;
import com.alibaba.nacos.plugin.datasource.mapper.ConfigInfoMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Configuration info mapper implementation for Highgo database.
*
* @Date: 2023/05/11
*/
public class ConfigurationInfoMapperByHighgo extends AbstractMapper implements ConfigInfoMapper {
private static final String CONFIG_ID = "dataId";
private static final String GROUP_NAME = "group";
private static final String APPLICATION_NAME = "appName";
private static final String CONTENT_DATA = "content";
private static final String NAMESPACE = "tenant";
@Override
public MapperResult findConfigInfoByAppFetchRows(MapperContext context) {
final String application = (String) context.getWhereParameter(FieldConstant.APP_NAME);
final String namespace = (String) context.getWhereParameter(FieldConstant.TENANT_ID);
String query = "SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info"
+ " WHERE tenant_id LIKE ? AND app_name= ?" + " OFFSET " + context.getStartRow() + " LIMIT " + context.getPageSize();
return new MapperResult(query, CollectionUtils.list(namespace, application));
}
@Override
public MapperResult getTenantIdList(MapperContext context) {
String query = "SELECT tenant_id FROM config_info WHERE tenant_id != '" + NamespaceUtil.getNamespaceDefaultId()
+ "' GROUP BY tenant_id OFFSET " + context.getStartRow() + " LIMIT " + context.getPageSize();
return new MapperResult(query, Collections.emptyList());
}
@Override
public MapperResult getGroupIdList(MapperContext context) {
String query = "SELECT group_id FROM config_info WHERE tenant_id ='" + NamespaceUtil.getNamespaceDefaultId()
+ "' GROUP BY group_id OFFSET " + context.getStartRow() + " LIMIT " + context.getPageSize();
return new MapperResult(query, Collections.emptyList());
}
@Override
public MapperResult findAllConfigKey(MapperContext context) {
String query = " SELECT data_id,group_id,app_name FROM ( "
+ " SELECT id FROM config_info WHERE tenant_id LIKE ? ORDER BY id OFFSET " + context.getStartRow() + " LIMIT "
+ context.getPageSize() + " )" + " g, config_info t WHERE g.id = t.id ";
return new MapperResult(query, CollectionUtils.list(context.getWhereParameter(FieldConstant.TENANT_ID)));
}
@Override
public MapperResult findAllConfigInfoBaseFetchRows(MapperContext context) {
String query = "SELECT t.id,data_id,group_id,content,md5"
+ " FROM ( SELECT id FROM config_info ORDER BY id OFFSET ? LIMIT ? ) "
+ " g, config_info t WHERE g.id = t.id ";
return new MapperResult(query, Collections.emptyList());
}
@Override
public MapperResult findAllConfigInfoFragment(MapperContext context) {
String contextParam = context.getContextParameter(ContextConstant.NEED_CONTENT);
boolean requireContent = contextParam != null && Boolean.parseBoolean(contextParam);
String query = "SELECT id,data_id,group_id,tenant_id,app_name," + (requireContent ? "content," : "")
+ "md5,gmt_modified,type,encrypted_data_key FROM config_info WHERE id > ? ORDER BY id ASC OFFSET "
+ context.getStartRow() + " LIMIT " + context.getPageSize();
return new MapperResult(query, CollectionUtils.list(context.getWhereParameter(FieldConstant.ID)));
}
@Override
public MapperResult findChangeConfigFetchRows(MapperContext context) {
final String namespace = (String) context.getWhereParameter(FieldConstant.TENANT_ID);
final String configId = (String) context.getWhereParameter(FieldConstant.DATA_ID);
final String group = (String) context.getWhereParameter(FieldConstant.GROUP_ID);
final String application = (String) context.getWhereParameter(FieldConstant.APP_NAME);
final String namespaceTemp = com.alibaba.nacos.common.utils.StringUtils.isBlank(namespace)
? com.alibaba.nacos.common.utils.StringUtils.EMPTY : namespace;
final Timestamp startTime = (Timestamp) context.getWhereParameter(FieldConstant.START_TIME);
final Timestamp endTime = (Timestamp) context.getWhereParameter(FieldConstant.END_TIME);
List<Object> params = new ArrayList<>();
final String sqlFetchRows = "SELECT id,data_id,group_id,tenant_id,app_name,type,md5,gmt_modified FROM config_info WHERE ";
String whereClause = " 1=1 ";
if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(configId)) {
whereClause += " AND data_id LIKE ? ";
params.add(configId);
}
if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(group)) {
whereClause += " AND group_id LIKE ? ";
params.add(group);
}
if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(namespaceTemp)) {
whereClause += " AND tenant_id = ? ";
params.add(namespaceTemp);
}
if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(application)) {
whereClause += " AND app_name = ? ";
params.add(application);
}
if (startTime != null) {
whereClause += " AND gmt_modified >=? ";
params.add(startTime);
}
if (endTime != null) {
whereClause += " AND gmt_modified <=? ";
params.add(endTime);
}
return new MapperResult(
sqlFetchRows + whereClause + " AND id > " + context.getWhereParameter(FieldConstant.LAST_MAX_ID)
+ " ORDER BY id ASC" + " OFFSET " + 0 + " LIMIT " + context.getPageSize(), params);
}
@Override
public MapperResult listGroupKeyMd5ByPageFetchRows(MapperContext context) {
String query = "SELECT t.id,data_id,group_id,tenant_id,app_name,md5,type,gmt_modified,encrypted_data_key FROM "
+ "( SELECT id FROM config_info ORDER BY id OFFSET " + context.getStartRow() + " LIMIT "
+ context.getPageSize() + " ) g, config_info t WHERE g.id = t.id";
return new MapperResult(query, Collections.emptyList());
}
@Override
public MapperResult findConfigInfoBaseLikeFetchRows(MapperContext context) {
final String configId = (String) context.getWhereParameter(FieldConstant.DATA_ID);
final String group = (String) context.getWhereParameter(FieldConstant.GROUP_ID);
final String content = (String) context.getWhereParameter(FieldConstant.CONTENT);
final String sqlFetchRows = "SELECT id,data_id,group_id,tenant_id,content FROM config_info WHERE ";
String whereClause = " 1=1 AND tenant_id='" + NamespaceUtil.getNamespaceDefaultId() + "' ";
List<Object> params = new ArrayList<>();
if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(configId)) {
whereClause += " AND data_id LIKE ? ";
params.add(configId);
}
if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(group)) {
whereClause += " AND group_id LIKE ";
params.add(group);
}
if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(content)) {
whereClause += " AND content LIKE ? ";
params.add(content);
}
return new MapperResult(sqlFetchRows + whereClause + " OFFSET " + context.getStartRow() + " LIMIT " + context.getPageSize(),
params);
}
@Override
public MapperResult findConfigInfo4PageFetchRows(MapperContext context) {
final String namespace = (String) context.getWhereParameter(FieldConstant.TENANT_ID);
final String configId = (String) context.getWhereParameter(FieldConstant.DATA_ID);
final String group = (String) context.getWhereParameter(FieldConstant.GROUP_ID);
final String application = (String) context.getWhereParameter(FieldConstant.APP_NAME);
final String content = (String) context.getWhereParameter(FieldConstant.CONTENT);
List<Object> params = new ArrayList<>();
final String query = "SELECT id,data_id,group_id,tenant_id,app_name,content,type,encrypted_data_key FROM config_info";
StringBuilder whereClause = new StringBuilder(" WHERE ");
whereClause.append(" tenant_id=? ");
params.add(namespace);
if (com.alibaba.nacos.common.utils.StringUtils.isNotBlank(configId)) {
whereClause.append(" AND data_id=? ");
params.add(configId);
}
if (com.alibaba.nacos.common.utils.StringUtils.isNotBlank(group)) {
whereClause.append(" AND group_id=? ");
params.add(group);
}
if (com.alibaba.nacos.common.utils.StringUtils.isNotBlank(application)) {
whereClause.append(" AND app_name=? ");
params.add(application);
}
if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(content)) {
whereClause.append(" AND content LIKE ? ");
params.add(content);
}
return new MapperResult(query + whereClause + " OFFSET " + context.getStartRow() + " LIMIT " + context.getPageSize(),
params);
}
@Override
public MapperResult findConfigInfoBaseByGroupFetchRows(MapperContext context) {
String query = "SELECT id,data_id,group_id,content FROM config_info WHERE group_id=? AND tenant_id=?" + " OFFSET "
+ context.getStartRow() + " LIMIT " + context.getPageSize();
return new MapperResult(query, CollectionUtils.list(context.getWhereParameter(FieldConstant.GROUP_ID),
context.getWhereParameter(FieldConstant.TENANT_ID)));
}
@Override
public MapperResult findConfigInfoLike4PageFetchRows(MapperContext context) {
final String namespace = (String) context.getWhereParameter(FieldConstant.TENANT_ID);
final String configId = (String) context.getWhereParameter(FieldConstant.DATA_ID);
final String group = (String) context.getWhereParameter(FieldConstant.GROUP_ID);
final String application = (String) context.getWhereParameter(FieldConstant.APP_NAME);
final String content = (String) context.getWhereParameter(FieldConstant.CONTENT);
List<Object> params = new ArrayList<>();
final String sqlFetchRows = "SELECT id,data_id,group_id,tenant_id,app_name,content,encrypted_data_key FROM config_info";
StringBuilder whereClause = new StringBuilder(" WHERE ");
whereClause.append(" tenant_id LIKE ? ");
params.add(namespace);
if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(configId)) {
whereClause.append(" AND data_id LIKE ? ");
params.add(configId);
}
if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(group)) {
whereClause.append(" AND group_id LIKE ? ");
params.add(group);
}
if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(application)) {
whereClause.append(" AND app_name = ? ");
params.add(application);
}
if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(content)) {
whereClause.append(" AND content LIKE ? ");
params.add(content);
}
return new MapperResult(sqlFetchRows + whereClause + " OFFSET " + context.getStartRow() + " LIMIT " + context.getPageSize(),
params);
}
@Override
public MapperResult findAllConfigInfoFetchRows(MapperContext context) {
String query = "SELECT t.id,data_id,group_id,tenant_id,app_name,content,md5 "
+ " FROM ( SELECT id FROM config_info WHERE tenant_id LIKE ? ORDER BY id OFFSET ? LIMIT ? )"
+ " g, config_info t WHERE g.id = t.id ";
return new MapperResult(query,
CollectionUtils.list(context.getWhereParameter(FieldConstant.TENANT_ID), context.getStartRow(),
context.getPageSize()));
}
@Override
public String getDataSource() {
return DataSourceConstant.HIGHGO;
}
}
com.alibaba.nacos.plugin.datasource.mapper.Mapperファイル
plugin/datasource/src/main/resources/META-INF/services
com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoAggrMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoBetaMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoTagMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigTagsRelationMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.HistoryConfigInfoMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.TenantInfoMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.TenantCapacityMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.GroupCapacityMapperByMysql
com.alibaba.nacos.plugin.datasource.impl.derby.ConfigInfoAggrMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.ConfigInfoBetaMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.ConfigInfoMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.ConfigInfoTagMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.ConfigInfoTagsRelationMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.HistoryConfigInfoMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.TenantInfoMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.TenantCapacityMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.GroupCapacityMapperByDerby
-- 瀚高用追加
com.alibaba.nacos.plugin.datasource.impl.highgo.ConfigurationAggregateMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.ConfigurationBetaMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.ConfigurationInfoMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.ConfigurationInfoTagMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.ConfigurationTagsRelationshipMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.HistoricalConfigurationInfoMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.TenantInfoMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.TenantQuotaMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.GroupQuotaMapperByHighgo
5. nacos-consoleモジュールの修正
瀚高データベースでは、currentSchema=nacos_config を追加する必要があります。追加しないとデータベースに接続できません。
console/src/main/resources/application.properties
spring.sql.init.platform=highgo
db.num=1
db.url.0=jdbc:highgo://xxxx:5866/nacos_config?currentSchema=nacos_config&characterEncoding=utf8&connectTimeout=10000&socketTimeout=30000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=nacos
db.password.0=nacos
db.pool.config.driverClassName=com.highgo.jdbc.Driver
6. 単体起動
起動時に -Dnacos.standalone=true パラメータを追加して単体起動であることを示します
7. パッケージング
mvn -Prelease-nacos -Dmaven.test.skip=true -Dpmd.skip=true -Dcheckstyle.skip=true clean install -U
nacos-2.2.0\distribution\target下に圧縮ファイルが生成され、直接使用できます
8. ARMアーキテクチャ対応
8.1 ソースコードとbuild/Dockerfile.Slimに対応するイメージをダウンロード
対応するバージョンのnacos-dockerを探す
https://github.com/nacos-group/nacos-docker/tree/v2.3.1
対応するイメージをダウンロード
https://hub.docker.com/_/buildpack-deps/tags?page=&page_size=&ordering=&name=buster-curl
https://hub.docker.com/r/adoptopenjdk/openjdk8/tags?page=2&page_size=&name=jre8u372-b07&ordering=
8.2 naocsソースコードのルートディレクトリに2つのファイルを追加し、修正後に直接イメージをアップロードできるようにする
"""
/*
* Copyright 1999-2021 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"""
pipeline {
agent {
docker {
image 'reg.xxx.com/library/arm64/maven-arm64:3.5.3'
args '-v /root/.m2:/root/.m2 -v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/kubectl:/usr/bin/kubectl'
label 'arm64'
}
}
stages {
stage('build') {
steps {
sh 'mvn -Prelease-nacos -Dmaven.test.skip=true -Dpmd.skip=true -Dcheckstyle.skip=true clean install -U'
}
}
stage('deploy') {
steps {
withCredentials([usernamePassword(credentialsId: 'harbor-xxx', passwordVariable: 'HPASSWD', usernameVariable: 'HUSER')]) {
sh '''
docker build -f Dockerfile_arm -t reg.xxx.com/dev/arm64/nacos-arm64-linux:2.3.1 .
docker login reg.sdses.com -u $HUSER -p $HPASSWD
docker push reg.xxx.com/dev/arm64/nacos-arm64-linux:2.3.1
'''
}
}
}
}
}
DockerFile
#
# Copyright 1999-2021 Alibaba Group Holding Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
FROM reg.xxx.com/library/arm64/buildpack-deps:buster-curl as installer
ARG NACOS_VERSION=2.3.1
ARG HOT_FIX_FLAG=""
COPY distribution/target/nacos-server-2.3.1.tar.gz /var/tmp/
RUN tar -xzvf /var/tmp/nacos-server-2.3.1.tar.gz -C /home/
FROM reg.xxx.com/library/arm64/nacos/openjdk8:jre8u372-b07
# set environment
ENV MODE="cluster" \
PREFER_HOST_MODE="ip"\
BASE_DIR="/home/nacos" \
CLASSPATH=".:/home/nacos/conf:$CLASSPATH" \
CLUSTER_CONF="/home/nacos/conf/cluster.conf" \
FUNCTION_MODE="all" \
NACOS_USER="nacos" \
JAVA="/opt/java/openjdk/bin/java" \
JVM_XMS="1g" \
JVM_XMX="1g" \
JVM_XMN="512m" \
JVM_MS="128m" \
JVM_MMS="320m" \
NACOS_DEBUG="n" \
TOMCAT_ACCESSLOG_ENABLED="false" \
TZ="Asia/Shanghai"
WORKDIR $BASE_DIR
# copy nacos bin
COPY --from=installer ["/home/nacos", "/home/nacos"]
ADD build/bin/docker-startup.sh bin/docker-startup.sh
#ADD conf/application.properties conf/application.properties
# set startup log dir
RUN mkdir -p logs \
&& cd logs \
&& touch start.out \
&& ln -sf /dev/stdout start.out \
&& ln -sf /dev/stderr start.out
RUN chmod +x bin/docker-startup.sh
EXPOSE 8848
ENTRYPOINT ["bin/docker-startup.sh"]