new build
This commit is contained in:
13
.github/workflows/docker-build-self.yml
vendored
13
.github/workflows/docker-build-self.yml
vendored
@@ -17,6 +17,19 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: '1.24'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
go mod download
|
||||||
|
go mod tidy
|
||||||
|
- name: Build Go application
|
||||||
|
run: |
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./server ./src
|
||||||
|
|
||||||
- name: Build Docker image
|
- name: Build Docker image
|
||||||
run: |
|
run: |
|
||||||
docker build -t "$IMAGE_NAME:latest" -t "$IMAGE_NAME:${{ github.run_number }}" .
|
docker build -t "$IMAGE_NAME:latest" -t "$IMAGE_NAME:${{ github.run_number }}" .
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
|
||||||
knet:
|
|
||||||
build: .
|
|
||||||
ports:
|
|
||||||
- "54321:54321"
|
|
||||||
environment:
|
|
||||||
- API_TOKEN=${API_TOKEN:-your-default-token}
|
|
||||||
- API_USERNAME=${API_USERNAME:-api}
|
|
||||||
- BUILD_NUMBER=${BUILD_NUMBER:-dev}
|
|
||||||
networks:
|
|
||||||
- monitoring
|
|
||||||
|
|
||||||
prometheus:
|
|
||||||
image: prom/prometheus:latest
|
|
||||||
container_name: knet-prometheus
|
|
||||||
ports:
|
|
||||||
- "9090:9090"
|
|
||||||
volumes:
|
|
||||||
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
|
||||||
- prometheus_data:/prometheus
|
|
||||||
command:
|
|
||||||
- '--config.file=/etc/prometheus/prometheus.yml'
|
|
||||||
- '--storage.tsdb.path=/prometheus'
|
|
||||||
- '--storage.tsdb.retention.time=30d'
|
|
||||||
- '--storage.tsdb.retention.size=10GB'
|
|
||||||
- '--web.console.libraries=/etc/prometheus/console_libraries'
|
|
||||||
- '--web.console.templates=/etc/prometheus/consoles'
|
|
||||||
- '--web.enable-lifecycle'
|
|
||||||
- '--web.enable-admin-api'
|
|
||||||
networks:
|
|
||||||
- monitoring
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
grafana:
|
|
||||||
image: grafana/grafana:latest
|
|
||||||
container_name: knet-grafana
|
|
||||||
ports:
|
|
||||||
- "3000:3000"
|
|
||||||
environment:
|
|
||||||
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
|
|
||||||
volumes:
|
|
||||||
- grafana_data:/var/lib/grafana
|
|
||||||
- ./grafana/provisioning:/etc/grafana/provisioning
|
|
||||||
networks:
|
|
||||||
- monitoring
|
|
||||||
restart: unless-stopped
|
|
||||||
depends_on:
|
|
||||||
- prometheus
|
|
||||||
|
|
||||||
networks:
|
|
||||||
monitoring:
|
|
||||||
driver: bridge
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
prometheus_data:
|
|
||||||
grafana_data:
|
|
||||||
28
dockerfile
28
dockerfile
@@ -1,29 +1,15 @@
|
|||||||
# Step 1: Build the Go binary in a separate stage
|
|
||||||
FROM golang:1.24 AS builder
|
|
||||||
|
|
||||||
# Set the working directory
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy the Go module files
|
|
||||||
COPY go.mod go.sum ./
|
|
||||||
RUN go mod download
|
|
||||||
|
|
||||||
# Copy the rest of the application code
|
|
||||||
COPY ./src ./src
|
|
||||||
|
|
||||||
# Build the Go binary with static linking for Linux
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o /server ./src
|
|
||||||
|
|
||||||
COPY ./views ./views
|
|
||||||
COPY ./build_number ./build_number
|
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|
||||||
# Set the current working directory inside the container
|
# Set the current working directory inside the container
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY . .
|
COPY ./server .
|
||||||
COPY --from=builder server ./
|
COPY ./views ./views
|
||||||
|
COPY ./data ./data
|
||||||
|
COPY ./js ./js
|
||||||
|
COPY ./css ./css
|
||||||
|
COPY ./build_number ./build_number
|
||||||
|
# COPY --from=builder server ./
|
||||||
|
|
||||||
# Command to run the executable
|
# Command to run the executable
|
||||||
CMD ["./server"]
|
CMD ["./server"]
|
||||||
|
|||||||
Reference in New Issue
Block a user