8000 add script to build ilogtail production image by yyuuttaaoo · Pull Request #190 · alibaba/loongcollector · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add script to build ilogtail production image #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
*.bak

# go
plugin_main/plugin_main
pluginmanager/checkpoint/
/plugin_main/plugin_main
/pluginmanager/checkpoint/
*.prof
plugin_main/checkpoint/*
/plugin_main/checkpoint/*
*.LOG
*.LOG.*
*.test
Expand All @@ -25,21 +25,22 @@ CMakeCache.txt
Makefile
*.cbp
*.a
core/log_pb/*.pb.*
core/build/
core/common/Version.cpp
core/installer/public/
/core/log_pb/*.pb.*
/core/build/
/core/common/Version.cpp
/core/installer/public/
!/Makefile
!core/dependencies.cmake
!core/utils.cmakels
!core/libulogfs.a

# output
e2e-test
bin/
build/
find_licenses/
/bin/
/generated_files/
/build/
/find_licenses/

# vscode
.vscode
!.vscode/settings.json
!.vscode/settings.json
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ plugin_main: clean
.PHONY: docker
docker: clean
./scripts/gen_build_scripts.sh all $(GENERATED_HOME) $(VERSION) $(DOCKER_REPOSITORY)
./scripts/docker_build.sh default $(GENERATED_HOME) $(VERSION) $(DOCKER_REPOSITORY) $(DOCKER_PUSH)
./scripts/docker_build.sh production $(GENERATED_HOME) $(VERSION) $(DOCKER_REPOSITORY) $(DOCKER_PUSH)

.PHONY: e2edocker
e2edocker: clean
./scripts/gen_build_scripts.sh e2e $(GENERATED_HOME) $(VERSION) $(DOCKER_REPOSITORY)
./scripts/docker_build.sh default $(GENERATED_HOME) $(VERSION) $(DOCKER_REPOSITORY) false
./scripts/docker_build.sh development $(GENERATED_HOME) $(VERSION) $(DOCKER_REPOSITORY) false

# provide a goc server for e2e testing
.PHONY: gocdocker
Expand Down
2 changes: 1 addition & 1 deletion core/app_config/AppConfigBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ void LoadEnvValueIfExisting(const char* envKey, T& cfgValue) {

void AppConfigBase::LoadEnvResourceLimit() {
LoadSingleValueEnvConfig("cpu_usage_limit", mCpuUsageUpLimit, (float)0.4);
LoadSingleValueEnvConfig("mem_usage_limit", mMemUsageUpLimit, (int64_t)100);
LoadSingleValueEnvConfig("mem_usage_limit", mMemUsageUpLimit, (int64_t)384);
LoadSingleValueEnvConfig("max_bytes_per_sec", mMaxBytePerSec, (int32_t)(1024 * 1024));
LoadSingleValueEnvConfig("process_thread_count", mProcessThreadCount, (int32_t)1);
LoadSingleValueEnvConfig("send_request_concurrency", mSendRequestConcurrency, (int32_t)2);
Expand Down
14 changes: 14 additions & 0 deletions core/logtail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ DEFINE_FLAG_INT32(fork_interval, "fork dispatcher process interval", 10);
DECLARE_FLAG_INT32(max_open_files_limit);
DECLARE_FLAG_INT32(max_reader_open_files);
DECLARE_FLAG_STRING(ilogtail_config_env_name);
DECLARE_FLAG_STRING(logtail_sys_conf_dir);
DECLARE_FLAG_STRING(check_point_filename);
DECLARE_FLAG_STRING(default_buffer_file_path);
DECLARE_FLAG_STRING(ilogtail_docker_file_path_config);

void HandleSighupSignal(int signum, siginfo_t* info, void* context) {
ConfigManager::GetInstance()->SetMappingPathsChanged();
Expand Down Expand Up @@ -90,6 +94,14 @@ void enable_core(void) {
}
}

static void overwrite_community_edition_flags() {
// support run in installation dir on default
STRING_FLAG(logtail_sys_conf_dir) = ".";
STRING_FLAG(check_point_filename) = "checkpoint/logtail_check_point";
STRING_FLAG(default_buffer_file_path) = "checkpoint";
STRING_FLAG(ilogtail_docker_file_path_config) = "checkpoint/docker_path_config.json";
}

// Main routine of worker process.
void do_worker_process() {
Logger::Instance().InitGlobalLoggers();
Expand Down Expand Up @@ -144,6 +156,8 @@ void do_worker_process() {
AppConfig::GetInstance()->SetWorkingDir(GetProcessExecutionDir());
}

overwrite_community_edition_flags();

char* configEnv = getenv(STRING_FLAG(ilogtail_config_env_name).c_str());
if (configEnv == NULL || strlen(configEnv) == 0) {
AppConfig::GetInstance()->LoadAppConfig(STRING_FLAG(ilogtail_config));
Expand Down
12 changes: 12 additions & 0 deletions core/logtail_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ using namespace logtail;

DEFINE_FLAG_STRING(ilogtail_daemon_startup_hints, "hints passed from daemon during startup", "");
DECLARE_FLAG_STRING(ilogtail_config_env_name);
DECLARE_FLAG_STRING(logtail_sys_conf_dir);
DECLARE_FLAG_STRING(check_point_filename);
DECLARE_FLAG_STRING(default_buffer_file_path);
DECLARE_FLAG_STRING(ilogtail_docker_file_path_config);

static void overwrite_community_edition_flags() {
// support run in installation dir on default
STRING_FLAG(logtail_sys_conf_dir) = ".";
STRING_FLAG(check_point_filename) = "checkpoint/logtail_check_point";
STRING_FLAG(default_buffer_file_path) = "checkpoint";
STRING_FLAG(ilogtail_docker_file_path_config) = "checkpoint/docker_path_config.json";
}

void do_worker_process() {
Logger::Instance().InitGlobalLoggers();
Expand Down
File renamed without changes.
42 changes: 42 additions & 0 deletions docker/Dockerfile_production_part
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2021 iLogtail Authors
#
# 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 centos:centos7.9.2009
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]

ARG HOST_OS=Linux
ARG VERSION=1.1.0

WORKDIR /usr/local/ilogtail

COPY --from=build /src/bin/libPluginBase.so /usr/local/ilogtail/
COPY --from=build /src/example_config/start_with_container/ilogtail_config.json /usr/local/ilogtail/
COPY --from=build /src/core/build/ilogtail /usr/local/ilogtail/
COPY --from=build /src/core/build/plugin/libPluginAdapter.so /usr/local/ilogtail/
COPY --from=build /src/scripts/run_ilogtail.sh /usr/local/ilogtail/

RUN chmod -R 755 /usr/local/ilogtail/
RUN mkdir /usr/local/ilogtail/checkpoint

ENTRYPOINT ["/usr/local/ilogtail/run_ilogtail.sh"]
4 changes: 1 addition & 3 deletions example_config/quick_start/ilogtail_config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"default_access_key_id": "",
F438 "default_access_key": "",
"logtail_sys_conf_dir": ".",
"check_point_filename": "checkpoint/logtail_check_point"
"default_access_key": ""
}
2 changes: 2 additions & 0 deletions example_config/start_with_container/ilogtail_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2022 iLogtail Authors
#
# 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.

# Copyright 2022 iLogtail Authors
#
# 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.

enable: true
inputs:
- Type: file_log
LogPath: /root
FilePattern: simple.log
DockerFile: true
flushers:
- Type: flusher_stdout
OnlyStdout: true
10000
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2022 iLogtail Authors
#
# 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.

# Copyright 2022 iLogtail Authors
#
# 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.

enable: true
inputs:
- Type: service_docker_stdout
BeginLineCheckLength: 10
BeginLineRegex: ".*"
Stderr: false
Stdout: true
flushers:
- Type: flusher_stdout
FileName: simple.stdout
12 changes: 8 additions & 4 deletions scripts/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
# limitations under the License.


# Currently, there are 3 supported docker categories, which are goc, build, and default.
# Currently, there are 4 supported docker categories, which are goc, build, development and production.
#
# goc: build goc server with Dockerfile_doc
# build: build core or plugin binary with Dockerfile_build
# default: build ilogtail images.
# development: build ilogtail development images.
# production: build ilogtail production images.
CATEGORY=$1
GENERATED_HOME=$2
VERSION=${3:-1.1.0}
Expand All @@ -36,9 +37,12 @@ touch $GEN_DOCKERFILE

if [[ $CATEGORY = "goc" || $CATEGORY = "build" ]]; then
cat $ROOTDIR/docker/Dockerfile_$CATEGORY|grep -v "#" > $GEN_DOCKERFILE;
elif [[ $CATEGORY = "default" ]]; then
elif [[ $CATEGORY = "development" ]]; then
cat $ROOTDIR/docker/Dockerfile_build |grep -v "#" > $GEN_DOCKERFILE;
cat $ROOTDIR/docker/Dockerfile_ilogtail_part |grep -v "#">> $GEN_DOCKERFILE;
cat $ROOTDIR/docker/Dockerfile_development_part |grep -v "#">> $GEN_DOCKERFILE;
elif [[ $CATEGORY = "production" ]]; then
cat $ROOTDIR/docker/Dockerfile_build |grep -v "#" > $GEN_DOCKERFILE;
cat $ROOTDIR/docker/Dockerfile_production_part |grep -v "#">> $GEN_DOCKERFILE;
fi

echo "=============DOCKERFILE=================="
Expand Down
2 changes: 1 addition & 1 deletion scripts/gen_build_scripts.sh
CC17
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function generateCopyScript() {
echo 'docker cp "$id":/src/core/build/ilogtail $BINDIR' >> $COPY_SCRIPT_FILE;
echo 'docker cp "$id":/src/core/build/plugin/libPluginAdapter.so $BINDIR' >> $COPY_SCRIPT_FILE;
else
echo ' docker cp "$id":/src/bin/libPluginBase.so $BINDIR' >> $COPY_SCRIPT_FILE;
echo 'docker cp "$id":/src/bin/libPluginBase.so $BINDIR' >> $COPY_SCRIPT_FILE;
echo 'docker cp "$id":/src/core/build/ilogtail $BINDIR' >> $COPY_SCRIPT_FILE;
echo 'docker cp "$id":/src/core/build/plugin/libPluginAdapter.so $BINDIR' >> $COPY_SCRIPT_FILE;
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/plugin_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ os
OS_FLAG=$?

ROOTDIR=$(cd $(dirname "${BASH_SOURCE[0]}") && cd .. && pwd)
mkdir "$ROOTDIR"/bin
mkdir -p "$ROOTDIR"/bin

if [ $OS_FLAG = 1 ]; then
IDFLAGS='-extldflags "-Wl,--wrap=memcpy"'
Expand Down
Loading
0