diff --git a/.dockerignore.yaml b/.dockerignore.yaml new file mode 100644 index 0000000..fb2ce37 --- /dev/null +++ b/.dockerignore.yaml @@ -0,0 +1,6 @@ +vendor/ + +.git/ +.gitea/ + +.env diff --git a/.env.docker.sample b/.env.docker.sample new file mode 100644 index 0000000..e08b415 --- /dev/null +++ b/.env.docker.sample @@ -0,0 +1,8 @@ +AUTH_URL=https://auth.txt.com +API_URL=https://txt.com +SERVICE_USERNAME=suave +SERVICE_PASSPHRASE=9238urc9328nr329 +TWILIO_AUTH_SID=9M438C93R943U4329MCU43C34U +TWILIO_SERVICE_SID=9M4J3X8439U398NUVT3342MC349C348T +TWILIO_AUTH_TOKEN="f4a1f2b0b79ea3735078c2d8ee9684e1" +TWILIO_PHONE_NUMBER=10123456789 diff --git a/.gitignore b/.gitignore index e623776..09d314c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ catapult .env .env.local +.env.docker diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0ff56b4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,45 @@ +FROM golang:1.25.4 AS builder + +WORKDIR /app + +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + openssh-client git + +RUN mkdir -p -m 0700 ~/.ssh && \ + ssh-keyscan git.kundeng.us >> ~/.ssh/known_hosts + +# Configure Git to use SSH for GitHub +RUN git config --global url."ssh://git@git.kundeng.us".insteadOf "https://git.kundeng.us" + +# Set up the Go environment for private modules +ENV GOPRIVATE=git.kundeng.us + +# Copy go mod and sum files +COPY go.mod go.sum ./ + +RUN --mount=type=ssh mkdir src && \ + go mod download + +# Copy source code +COPY ./cmd ./cmd +COPY ./internal ./internal +COPY ./Makefile . +COPY ./.env . + +# Build the application +RUN CGO_ENABLED=0 GOOS=linux make build + +# Runtime stage +FROM alpine:latest AS production + +RUN apk --no-cache add ca-certificates + +WORKDIR /root/ + +# Copy the pre-built binary file from the previous stage +COPY --from=builder /app/catapult . +COPY --from=builder /app/.env ./ + +# Command to run the executable +CMD ["./catapult"] diff --git a/docker-compose.taml b/docker-compose.taml new file mode 100644 index 0000000..40c3e93 --- /dev/null +++ b/docker-compose.taml @@ -0,0 +1,11 @@ +version: '3.8' # Use a recent version + +services: + catapult_service: + build: # Tells docker-compose to build the Dockerfile in the current directory + context: . + ssh: ["default"] # Uses host's SSH agent + container_name: catapult # Optional: Give the container a specific name + env_file: + - .env + restart: unless-stopped # Optional: Restart policy