build: add docker support
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
- Add Dockerfile for containerized deployment - Add .drone.yml for CI/CD pipeline configuration - Add docker and docker-run targets to Makefile - Configure port 8080 binding and persistent volume mount
This commit is contained in:
35
.drone.yml
Normal file
35
.drone.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: default
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
|
||||
steps:
|
||||
# Unit Tests
|
||||
- name: tests
|
||||
image: golang
|
||||
commands:
|
||||
- make tests
|
||||
|
||||
# Fetch Tags
|
||||
- name: fetch tags
|
||||
image: alpine/git
|
||||
commands:
|
||||
- git fetch --tags
|
||||
|
||||
# Publish Docker Image
|
||||
- name: publish docker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: gitea.va.reichard.io/evan/aethera
|
||||
registry: gitea.va.reichard.io
|
||||
tags:
|
||||
- dev
|
||||
custom_dns:
|
||||
- 8.8.8.8
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
68
Dockerfile
Normal file
68
Dockerfile
Normal file
@@ -0,0 +1,68 @@
|
||||
# Multi-stage build for Aethera
|
||||
# Stage 1: Build frontend assets
|
||||
FROM oven/bun:1 AS frontend-builder
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
# Copy frontend package files
|
||||
COPY frontend/package.json frontend/bun.lock ./
|
||||
|
||||
# Install dependencies
|
||||
RUN bun install --frozen-lockfile
|
||||
|
||||
# Copy frontend source code
|
||||
COPY frontend/ ./
|
||||
|
||||
# Build frontend assets
|
||||
RUN bun run build
|
||||
|
||||
# Stage 2: Build Go binary
|
||||
FROM golang:1.25-alpine AS backend-builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache git
|
||||
|
||||
# Copy go mod files
|
||||
COPY backend/go.mod backend/go.sum ./
|
||||
|
||||
# Download Go dependencies
|
||||
RUN go mod download
|
||||
|
||||
# Copy backend source code
|
||||
COPY backend/ ./
|
||||
|
||||
# Copy frontend assets from previous stage
|
||||
COPY --from=frontend-builder /app/frontend/public/dist ./public/dist
|
||||
COPY --from=frontend-builder /app/frontend/public/index.html ./public/
|
||||
COPY --from=frontend-builder /app/frontend/public/pages ./public/pages
|
||||
|
||||
# Build the Go binary
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o aethera ./cmd
|
||||
|
||||
# Stage 3: Create minimal runtime image
|
||||
FROM alpine:3.21
|
||||
|
||||
# Install ca-certificates for HTTPS calls
|
||||
RUN apk add --no-cache ca-certificates
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the binary from the builder stage
|
||||
COPY --from=backend-builder /app/aethera .
|
||||
|
||||
# Copy static assets
|
||||
COPY --from=backend-builder /app/public ./public
|
||||
|
||||
# Create data directory
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
# Expose the default port
|
||||
EXPOSE 8080
|
||||
|
||||
# Set the entrypoint
|
||||
ENTRYPOINT ["./aethera"]
|
||||
|
||||
# Default command with recommended production settings
|
||||
CMD ["--listen", "0.0.0.0", "--port", "8080", "--data-dir", "/app/data"]
|
||||
5
Makefile
5
Makefile
@@ -1,4 +1,4 @@
|
||||
.PHONY: all frontend backend clean dev docker docker-run
|
||||
.PHONY: all frontend backend clean dev docker docker-run tests
|
||||
|
||||
all: frontend backend
|
||||
|
||||
@@ -21,3 +21,6 @@ docker:
|
||||
|
||||
docker-run:
|
||||
docker run -p 8080:8080 -v aethera-data:/app/data aethera
|
||||
|
||||
tests:
|
||||
cd backend && go test ./...
|
||||
|
||||
Reference in New Issue
Block a user