tsk-10: Dockerize app (#17)
Closes #10 Reviewed-on: #17 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
vendor/
|
||||
|
||||
.git/
|
||||
.gitea/
|
||||
|
||||
.env
|
||||
@@ -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
|
||||
@@ -3,3 +3,4 @@ catapult
|
||||
|
||||
.env
|
||||
.env.local
|
||||
.env.docker
|
||||
|
||||
+45
@@ -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"]
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user