Refactor docker script to support override
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
_working
|
_working
|
||||||
server
|
server
|
||||||
server.toml
|
server.toml
|
||||||
|
docker/docker-compose.override.yml
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
FROM golang:1.19-bullseye
|
FROM golang:1.19-bullseye
|
||||||
MAINTAINER restitux <restitux@ohea.xyz>
|
MAINTAINER restitux <restitux@ohea.xyz>
|
||||||
|
|
||||||
# Install connect proto build deps
|
|
||||||
RUN GOPATH="/go-bin" go install github.com/bufbuild/buf/cmd/buf@latest && \
|
|
||||||
GOPATH="/go-bin" go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest && \
|
|
||||||
GOPATH="/go-bin" go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \
|
|
||||||
GOPATH="/go-bin" go install github.com/bufbuild/connect-go/cmd/protoc-gen-connect-go@latest
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
ENTRYPOINT ["/build/docker/build-and-run.sh"]
|
ENTRYPOINT ["/build/server/docker/build-and-run.sh"]
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cd /build
|
cd /build/server
|
||||||
go build .
|
go build .
|
||||||
./server
|
./server
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "0.0.0.0:45420:45420"
|
- "0.0.0.0:45420:45420"
|
||||||
volumes:
|
volumes:
|
||||||
- "..:/build"
|
- "..:/build/server"
|
||||||
- "../server.toml:/root/.config/cursorius/server.toml"
|
- "../server.toml:/root/.config/cursorius/server.toml"
|
||||||
- "/var/run/docker.sock:/var/run/docker.sock"
|
- "/var/run/docker.sock:/var/run/docker.sock"
|
||||||
- "../_working/go:/go"
|
- "../_working/go:/go"
|
||||||
|
|||||||
+34
-10
@@ -5,32 +5,56 @@ set -e
|
|||||||
mkdir -p _working/go
|
mkdir -p _working/go
|
||||||
mkdir -p _working/jobs
|
mkdir -p _working/jobs
|
||||||
|
|
||||||
|
base_default_compose_files="docker/docker-compose.yml"
|
||||||
|
default_compose_files="$base_default_compose_files"
|
||||||
|
|
||||||
|
if [ -f "docker/docker-compose.override.yml" ]
|
||||||
|
then
|
||||||
|
default_compose_files+=" docker/docker-compose.override.yml"
|
||||||
|
else
|
||||||
|
default_compose_files="docker/docker-compose.yml"
|
||||||
|
fi
|
||||||
|
|
||||||
function stop_containers {
|
function stop_containers {
|
||||||
docker compose -f docker/docker-compose.yml down
|
current_containers="$(cat _working/current_containers)"
|
||||||
docker compose -f docker/docker-compose.yml -f docker/webhook-override.yml down
|
if [ "$current_containers" == "default" ]
|
||||||
|
then
|
||||||
|
compose_files="$default_compose_files"
|
||||||
|
elif [ "$current_containers" == "webhook" ]
|
||||||
|
then
|
||||||
|
compose_files="$default_compose_files docker/webhook-override.yml"
|
||||||
|
fi
|
||||||
|
compose_file_flags=$(echo "$compose_files" | tr ' ' '\n' | xargs -I'{}' echo "-f {} " | tr -d '\n')
|
||||||
|
docker compose $compose_file_flags down
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_logs {
|
function show_logs {
|
||||||
current_containers="$(cat _working/current_containers)"
|
current_containers="$(cat _working/current_containers)"
|
||||||
if [[ "$current_containers" == "default" ]]
|
if [ "$current_containers" == "default" ]
|
||||||
then
|
then
|
||||||
docker compose -f docker/docker-compose.yml logs -f
|
compose_files="$default_compose_files"
|
||||||
elif [[ "$current_containers" == "webhook" ]]
|
elif [ "$current_containers" == "webhook" ]
|
||||||
then
|
then
|
||||||
docker compose -f docker/docker-compose.yml -f docker/webhook-override.yml logs -f
|
compose_files="$default_compose_files docker/webhook-override.yml"
|
||||||
fi
|
fi
|
||||||
|
compose_file_flags=$(echo "$compose_files" | tr ' ' '\n' | xargs -I'{}' echo "-f {} " | tr -d '\n')
|
||||||
|
docker compose $compose_file_flags logs -f
|
||||||
}
|
}
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
"default")
|
"default")
|
||||||
echo "default" > _working/current_containers
|
echo "default" > _working/current_containers
|
||||||
docker compose -f docker/docker-compose.yml up --build -d
|
compose_files="$default_compose_files"
|
||||||
docker compose -f docker/docker-compose.yml logs -f;;
|
compose_file_flags=$(echo "$compose_files" | tr ' ' '\n' | xargs -I'{}' echo "-f {} " | tr -d '\n')
|
||||||
|
docker compose $compose_file_flags up --build -d
|
||||||
|
docker compose $compose_file_flags logs -f;;
|
||||||
"webhook")
|
"webhook")
|
||||||
echo "webhook" > _working/current_containers
|
echo "webhook" > _working/current_containers
|
||||||
stop_containers
|
stop_containers
|
||||||
docker compose -f docker/docker-compose.yml -f docker/webhook-override.yml up --build -d
|
compose_files="$default_compose_files docker/webhook-override.yml"
|
||||||
docker compose -f docker/docker-compose.yml -f docker/webhook-override.yml logs -f;;
|
compose_file_flags=$(echo "$compose_files" | tr ' ' '\n' | xargs -I'{}' echo "-f {} " | tr -d '\n')
|
||||||
|
docker compose $compose_file_flags up --build -d
|
||||||
|
docker compose $compose_file_flags logs -f;;
|
||||||
"stop")
|
"stop")
|
||||||
stop_containers;;
|
stop_containers;;
|
||||||
"logs")
|
"logs")
|
||||||
|
|||||||
Reference in New Issue
Block a user