Skip to content

Commit

Permalink
init Makefile and hack
Browse files Browse the repository at this point in the history
  • Loading branch information
sjcsjc123 committed Jan 15, 2024
1 parent faaed9f commit b408027
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
9 changes: 9 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ubuntu:18.04

WORKDIR /app

COPY bin/flydb-server /app/flydb-server

RUN chmod +x /app/flydb-server

CMD ["/app/flydb-server"]
31 changes: 26 additions & 5 deletions hack/build-docker-image.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
#!/bin/bash

DOCKER_USERNAME="$DOCKER_USERNAME"
IMAGE_NAME="$IMAGE_NAME"
TAG="$TAG"
# 提示用户输入 Docker Hub 相关信息
# shellcheck disable=SC2162
read -p "Please enter your Docker Hub username: " DOCKER_USERNAME
# shellcheck disable=SC2162
read -p "Please enter image name: " IMAGE_NAME
# shellcheck disable=SC2162
read -p "Please enter image tag: " TAG

# check docker command
if ! [ -x "$(command -v docker)" ]; then
echo "Docker is not installed"
exit 1
fi

# check go command
if ! [ -x "$(command -v go)" ]; then
echo "Go is not installed"
exit 1
fi

# check environment variables
if [ -z "$DOCKER_USERNAME" ] || [ -z "$IMAGE_NAME" ] || [ -z "$TAG" ]; then
echo "Please set DOCKER_USERNAME, IMAGE_NAME and TAG environment variables"
exit 1
fi

docker build -t $DOCKER_USERNAME/$IMAGE_NAME:$TAG .
go build -o bin/flydb-server cmd/server/cli/flaydb-server.go

# build docker image
docker build -t DOCKER_USERNAME/IMAGE_NAME:TAG -f docker/Dockerfile .

# docker login

docker push $DOCKER_USERNAME/$IMAGE_NAME:$TAG
# push docker image
docker push DOCKER_USERNAME/IMAGE_NAME:TAG

# docker rmi $DOCKER_USERNAME/$IMAGE_NAME:$TAG

0 comments on commit b408027

Please sign in to comment.