Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f1b01ec18f | |||
| d271a786d2 | |||
| 005d0aa683 | |||
| 57624f5953 | |||
| 7b0356422d |
@@ -128,9 +128,9 @@ jobs:
|
||||
- name: Deploy via SSH
|
||||
if: success()
|
||||
run: |
|
||||
if [ -z "${{ secrets.DEPLOY_SSH_HOST }}" ]; then
|
||||
echo "DEPLOY_SSH_HOST not set, skip deploy"
|
||||
exit 0
|
||||
if command -v apk &> /dev/null; then
|
||||
apk add --no-cache sshpass openssh-client
|
||||
elif command -v apt-get &> /dev/null; then
|
||||
apt-get update && apt-get install -y sshpass openssh-client
|
||||
fi
|
||||
apk add --no-cache sshpass openssh-client 2>/dev/null || (apt-get update && apt-get install -y sshpass openssh-client) 2>/dev/null || true
|
||||
sshpass -p "${{ secrets.DEPLOY_SSH_PASS }}" ssh -o StrictHostKeyChecking=no -p ${{ secrets.DEPLOY_SSH_PORT || 22 }} ${{ secrets.DEPLOY_SSH_USER }}@${{ secrets.DEPLOY_SSH_HOST }} "cd ${{ secrets.DEPLOY_DIR || '/opt/nuyue' }} && docker compose pull && docker compose up -d"
|
||||
sshpass -p "${{ secrets.DEPLOY_SSH_PASS }}" ssh -o StrictHostKeyChecking=no -p "${{ secrets.DEPLOY_SSH_PORT }}" "${{ secrets.DEPLOY_SSH_USER }}"@"${{ secrets.DEPLOY_SSH_HOST }}" "cd ${{ secrets.DEPLOY_DIR }} && docker compose pull && docker compose up -d"
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
# Build stage
|
||||
FROM golang:1.24-alpine AS builder
|
||||
|
||||
ENV GOTOOLCHAIN=auto
|
||||
|
||||
# Install build dependencies for SQLite3
|
||||
RUN apk add --no-cache git gcc musl-dev
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy go mod files
|
||||
COPY server/go.mod server/go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy source code
|
||||
COPY server/ ./
|
||||
COPY agent/ ../agent/
|
||||
|
||||
# Build server with CGO enabled for SQLite3
|
||||
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w -linkmode external -extldflags '-static'" -o /nuyue-server ./cmd/server
|
||||
|
||||
# Build agent (no CGO needed)
|
||||
RUN cd ../agent && CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /nuyue-agent ./cmd/agent
|
||||
|
||||
# Runtime stage
|
||||
FROM alpine:3.19
|
||||
|
||||
RUN apk add --no-cache ca-certificates tzdata
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy binaries
|
||||
COPY --from=builder /nuyue-server /app/
|
||||
COPY --from=builder /nuyue-agent /app/
|
||||
|
||||
# Copy frontend (built by CI)
|
||||
COPY server/embed/dist /app/embed/dist
|
||||
|
||||
# Expose ports
|
||||
EXPOSE 8080 9090
|
||||
|
||||
# Run server
|
||||
CMD ["/app/nuyue-server"]
|
||||
Reference in New Issue
Block a user