Bug fixing
This commit is contained in:
10
.docker/.docker_config.json
Normal file
10
.docker/.docker_config.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"write_tokens": [
|
||||||
|
"fizzle1",
|
||||||
|
"fizzle2",
|
||||||
|
"fizzle3"
|
||||||
|
],
|
||||||
|
"object_store_path": "/data/storage",
|
||||||
|
"host": "0.0.0.0",
|
||||||
|
"port": 8123
|
||||||
|
}
|
@@ -8,7 +8,7 @@ ARG TARGETARCH
|
|||||||
|
|
||||||
RUN mkdir -p /sos
|
RUN mkdir -p /sos
|
||||||
|
|
||||||
COPY --chmod=0755 exe/simple_object_storage-${TARGETOS}-${TARGETARCH} /sos/sos
|
COPY --chmod=0755 output/simple_object_storage.${TARGETARCH} /sos/sos
|
||||||
|
|
||||||
# Expose port
|
# Expose port
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
27
build-docker.sh
Executable file
27
build-docker.sh
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
|
||||||
|
# build the executable
|
||||||
|
${SCRIPT_DIR}/build.sh amd64
|
||||||
|
|
||||||
|
# build the docker image
|
||||||
|
docker buildx build --load -t gitea.jde.nz/public/simple-object-storage:test --platform linux/amd64 .
|
||||||
|
|
||||||
|
DATADIR="/home/${USER}/.simple_object_storage"
|
||||||
|
if [ ! -d "${DATADIR}" ]; then
|
||||||
|
mkdir -p "${DATADIR}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
CONFIGFILE="${SCRIPT_DIR}/.docker/config.json"
|
||||||
|
if [ ! -f "${CONFIGFILE}" ]; then
|
||||||
|
echo "Config file not found: ${CONFIGFILE}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
-p 8123:80 \
|
||||||
|
--name simple-object-storage-test \
|
||||||
|
-v ${DATADIR}:/data/storage \
|
||||||
|
-v ${CONFIGFILE}:/data/sos_config.json:ro \
|
||||||
|
gitea.jde.nz/public/simple-object-storage:test
|
56
build.sh
56
build.sh
@@ -6,7 +6,8 @@ set -e
|
|||||||
# DIRECTORIES
|
# DIRECTORIES
|
||||||
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
CACHE_DIR="${SCRIPT_DIR}/cache"
|
CACHE_DIR="${SCRIPT_DIR}/cache"
|
||||||
EXE_DIR="${SCRIPT_DIR}/exe"
|
EXE_DIR="${SCRIPT_DIR}/output"
|
||||||
|
PROJECTNAME="simple_object_storage"
|
||||||
|
|
||||||
rm -f ${EXE_DIR}/*
|
rm -f ${EXE_DIR}/*
|
||||||
|
|
||||||
@@ -29,31 +30,31 @@ function die() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function build() {
|
function build_amd64() {
|
||||||
ARCH=$1
|
# Build for amd64 (musl)
|
||||||
|
echo "Building for amd64 (musl)..."
|
||||||
|
cmake -B build_amd64 -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_C_COMPILER=x86_64-linux-musl-gcc \
|
||||||
|
-DCMAKE_CXX_COMPILER=x86_64-linux-musl-g++ \
|
||||||
|
-DCMAKE_EXE_LINKER_FLAGS="-static" \
|
||||||
|
-DCMAKE_CXX_FLAGS="-march=x86-64" .
|
||||||
|
cmake --build build_amd64 --target simple_object_storage --config Release -j"$JOBS"
|
||||||
|
mkdir -p ${EXE_DIR}
|
||||||
|
cp build_amd64/${PROJECTNAME} ${EXE_DIR}/${PROJECTNAME}.amd64
|
||||||
|
}
|
||||||
|
|
||||||
BUILD_NAME="build-${ARCH}"
|
function build_arm64() {
|
||||||
BUILD_DIR="${SCRIPT_DIR}/${BUILD_NAME}"
|
# Build for arm64 (musl)
|
||||||
mkdir -p ${BUILD_DIR}
|
echo "Building for arm64 (musl)..."
|
||||||
|
cmake -B build_arm64 -DCMAKE_BUILD_TYPE=Release \
|
||||||
DOCKCROSS_SCRIPT="${CACHE_DIR}/dockcross-${ARCH}"
|
-DCMAKE_C_COMPILER=aarch64-linux-musl-gcc \
|
||||||
|
-DCMAKE_CXX_COMPILER=aarch64-linux-musl-g++ \
|
||||||
if [ ! -f "${DOCKCROSS_SCRIPT}" ]; then
|
-DCMAKE_EXE_LINKER_FLAGS="-static" \
|
||||||
echo "Downloading dockcross-${ARCH}"
|
-DCMAKE_CXX_FLAGS="-march=armv8-a" \
|
||||||
docker run --rm "dockcross/${ARCH}-full" > "${DOCKCROSS_SCRIPT}"
|
-DCMAKE_SYSTEM_PROCESSOR=aarch64 .
|
||||||
chmod +x "${DOCKCROSS_SCRIPT}"
|
cmake --build build_arm64 --target simple_object_storage --config Release -j"$JOBS"
|
||||||
fi
|
mkdir -p ${EXE_DIR}
|
||||||
|
cp build_arm64/${PROJECTNAME} ${EXE_DIR}/${PROJECTNAME}.arm64
|
||||||
echo "Building $ARCH executable"
|
|
||||||
cd "${SCRIPT_DIR}"
|
|
||||||
"${DOCKCROSS_SCRIPT}" bash -c "cd ${BUILD_NAME} && cmake .. && make -j$(nproc)"
|
|
||||||
|
|
||||||
if [ ! -f ${BUILD_DIR}/simple_object_storage ]; then
|
|
||||||
die "Failed to build $ARCH executable"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Copying $ARCH executable to $EXE_DIR/simple_object_storage-$ARCH"
|
|
||||||
cp ${BUILD_DIR}/simple_object_storage $EXE_DIR/simple_object_storage-$ARCH
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#--------------------------------
|
#--------------------------------
|
||||||
@@ -72,14 +73,13 @@ fi
|
|||||||
|
|
||||||
if [ "$BUILDSTR" = "all" ] || [ "$BUILDSTR" = "arm64" ]; then
|
if [ "$BUILDSTR" = "all" ] || [ "$BUILDSTR" = "arm64" ]; then
|
||||||
title "Building linux-arm64 executable"
|
title "Building linux-arm64 executable"
|
||||||
build linux-arm64 || die "Failed to build linux-arm64 executable"
|
build_arm64 || die "Failed to build linux-arm64 executable"
|
||||||
echo "arm64 executable: ./simple_object_storage-linux-arm64"
|
echo "arm64 executable: ./simple_object_storage-linux-arm64"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$BUILDSTR" = "all" ] || [ "$BUILDSTR" = "amd64" ]; then
|
if [ "$BUILDSTR" = "all" ] || [ "$BUILDSTR" = "amd64" ]; then
|
||||||
title "Building linux-x86_64 executable"
|
title "Building linux-x86_64 executable"
|
||||||
build linux-x86_64 || die "Failed to build linux-x86_64 executable"
|
build_amd64 || die "Failed to build linux-x86_64 executable"
|
||||||
mv ${EXE_DIR}/simple_object_storage-linux-x86_64 ${EXE_DIR}/simple_object_storage-linux-amd64
|
|
||||||
echo "amd64 executable: ./simple_object_storage-linux-amd64"
|
echo "amd64 executable: ./simple_object_storage-linux-amd64"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@ bool initialize_server() {
|
|||||||
if (config_path.empty()) {
|
if (config_path.empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
std::cout << "Config file: " << config_path << std::endl;
|
||||||
|
|
||||||
ServerConfig config;
|
ServerConfig config;
|
||||||
if (!simple_object_storage::load_config(config_path, config)) {
|
if (!simple_object_storage::load_config(config_path, config)) {
|
||||||
|
Reference in New Issue
Block a user