fix: load config
This commit is contained in:
parent
99dafce303
commit
5d62b70e90
|
@ -0,0 +1,34 @@
|
||||||
|
# Start from the official Golang base image version 1.22
|
||||||
|
FROM golang:1.22-alpine as builder
|
||||||
|
|
||||||
|
# Set the Current Working Directory inside the container
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy go mod and sum files
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
|
||||||
|
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
# Copy the source code into the container
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the Go app
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o webhook-listener .
|
||||||
|
|
||||||
|
# Start a new stage from scratch using a slim version of Alpine for a smaller image size
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
WORKDIR /root/
|
||||||
|
|
||||||
|
# Copy the Pre-built binary file from the previous stage
|
||||||
|
COPY --from=builder /app/webhook-listener .
|
||||||
|
|
||||||
|
# Environment variable for the port, set a default value if not provided
|
||||||
|
ENV PORT=62082
|
||||||
|
|
||||||
|
# Expose the port specified by the PORT environment variable
|
||||||
|
EXPOSE $PORT
|
||||||
|
|
||||||
|
# Command to run the executable, modified to use the environment variable for the port
|
||||||
|
CMD ["./webhook-listener"]
|
|
@ -0,0 +1,45 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Define variables
|
||||||
|
IMAGE_NAME="gitea-webhook-listener"
|
||||||
|
DOCKERFILE_PATH="./"
|
||||||
|
VERSION_FILE="version.txt"
|
||||||
|
REGISTRY="registry.fungimail.llc"
|
||||||
|
NAMESPACE="urko"
|
||||||
|
|
||||||
|
# Version management
|
||||||
|
if [ ! -f "$VERSION_FILE" ]; then
|
||||||
|
echo "Version file not found, creating one with version 1..."
|
||||||
|
echo "1" > $VERSION_FILE
|
||||||
|
fi
|
||||||
|
|
||||||
|
VERSION=$(cat $VERSION_FILE)
|
||||||
|
echo "Current version is $VERSION."
|
||||||
|
|
||||||
|
# Increment the version
|
||||||
|
VERSION=$((VERSION+1))
|
||||||
|
echo "Incrementing to new version $VERSION..."
|
||||||
|
echo $VERSION > $VERSION_FILE
|
||||||
|
|
||||||
|
# Step 1: Build the Docker image with the new version tag
|
||||||
|
echo "Building Docker image $IMAGE_NAME:$VERSION..."
|
||||||
|
docker build -t $IMAGE_NAME:$VERSION $DOCKERFILE_PATH
|
||||||
|
|
||||||
|
# Step 1b: Tag the image for the registry with version
|
||||||
|
FULL_IMAGE_NAME_VERSION="${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:${VERSION}"
|
||||||
|
echo "Tagging image for registry as $FULL_IMAGE_NAME_VERSION..."
|
||||||
|
docker tag $IMAGE_NAME:$VERSION $FULL_IMAGE_NAME_VERSION
|
||||||
|
|
||||||
|
# Step 1c: Tag the image for the registry with 'latest'
|
||||||
|
FULL_IMAGE_NAME_LATEST="${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:latest"
|
||||||
|
echo "Tagging image for registry as $FULL_IMAGE_NAME_LATEST..."
|
||||||
|
docker tag $IMAGE_NAME:$VERSION $FULL_IMAGE_NAME_LATEST
|
||||||
|
|
||||||
|
# Step 1d: Push the versioned image to the Docker registry
|
||||||
|
echo "Pushing $FULL_IMAGE_NAME_VERSION to the Docker registry..."
|
||||||
|
docker push $FULL_IMAGE_NAME_VERSION
|
||||||
|
|
||||||
|
# Step 1e: Push the latest image to the Docker registry
|
||||||
|
echo "Pushing $FULL_IMAGE_NAME_LATEST to the Docker registry..."
|
||||||
|
docker push $FULL_IMAGE_NAME_LATEST
|
||||||
|
|
Loading…
Reference in New Issue