mirror of
https://github.com/lejianwen/rustdesk-api.git
synced 2025-11-29 08:33:21 +00:00
fix bug
This commit is contained in:
@@ -1,4 +1,26 @@
|
||||
# Ignore Docker Compose configuration files
|
||||
docker-compose.yaml
|
||||
Dcokerfile
|
||||
Dcokerfile.dev
|
||||
data
|
||||
|
||||
# Ignore development Dockerfile
|
||||
Dockerfile.dev
|
||||
|
||||
# Ignore the data directory
|
||||
data/
|
||||
|
||||
# Ignore version control system directories
|
||||
.git/
|
||||
|
||||
# Ignore log and temporary files
|
||||
*.log
|
||||
*.tmp
|
||||
*.swp
|
||||
|
||||
# Ignore editor/IDE configuration files
|
||||
.vscode/
|
||||
.idea/
|
||||
|
||||
# Ignore binaries and build cache
|
||||
release/
|
||||
bin/
|
||||
*.exe
|
||||
*.out
|
||||
@@ -1,36 +1,50 @@
|
||||
# Use build arguments for Go version and architecture
|
||||
ARG GO_VERSION=1.23.2
|
||||
ARG BUILDARCH
|
||||
ARG GO_VERSION=1.22
|
||||
ARG BUILDARCH=amd64
|
||||
|
||||
# Stage 1: Build the Go application with swag
|
||||
FROM golang:${GO_VERSION} AS builder
|
||||
# Stage 1: Builder Stage
|
||||
# FROM golang:${GO_VERSION}-alpine AS builder
|
||||
FROM crazymax/xgo:${GO_VERSION} AS builder
|
||||
|
||||
# Set up working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies and copy the source code
|
||||
COPY go.mod ./
|
||||
RUN go install github.com/swaggo/swag/cmd/swag@latest
|
||||
RUN go mod download
|
||||
# Step 1: Copy the source code
|
||||
COPY . .
|
||||
|
||||
#run the build script
|
||||
RUN chmod +x build.sh && ./build.sh
|
||||
# Step 2: Download dependencies
|
||||
RUN go mod tidy && go mod download
|
||||
|
||||
# Stage 2: Prepare the final image
|
||||
|
||||
# Step 3: Install swag and Run the build script
|
||||
RUN go install github.com/swaggo/swag/cmd/swag@latest && \
|
||||
swag init -g cmd/apimain.go --output docs/api --instanceName api --exclude http/controller/admin && \
|
||||
swag init -g cmd/apimain.go --output docs/admin --instanceName admin --exclude http/controller/api
|
||||
|
||||
# Build the Go application with CGO enabled and specified ldflags
|
||||
RUN CGO_ENABLED=1 GOOS=linux go build -a \
|
||||
-ldflags "-s -w --extldflags '-static -fpic'" \
|
||||
-installsuffix cgo -o release/apimain cmd/apimain.go
|
||||
|
||||
|
||||
# Stage 2: Final Image
|
||||
FROM alpine:latest
|
||||
|
||||
# Set up working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install necessary dependencies
|
||||
# Install necessary runtime dependencies
|
||||
RUN apk add --no-cache tzdata file
|
||||
|
||||
# Copy the built application from the builder stage
|
||||
# Copy the built application and resources from the builder stage
|
||||
COPY --from=builder /app/release /app/
|
||||
COPY --from=builder /app/conf /app/conf/
|
||||
COPY --from=builder /app/resources /app/resources/
|
||||
|
||||
# Ensure the binary is correctly built
|
||||
RUN file /app/apimain
|
||||
# Ensure the binary is correctly built and linked
|
||||
RUN file /app/apimain && \
|
||||
mkdir -p /app/data && \
|
||||
mkdir -p /app/runtime
|
||||
|
||||
# Set up a volume for persistent data
|
||||
VOLUME /app/data
|
||||
@@ -39,4 +53,4 @@ VOLUME /app/data
|
||||
EXPOSE 21114
|
||||
|
||||
# Define the command to run the application
|
||||
CMD ["app/apimain"]
|
||||
CMD ["./apimain"]
|
||||
@@ -3,17 +3,20 @@ services:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.dev
|
||||
args:
|
||||
- DOCS=""
|
||||
image: lejianwen/rustdesk-api
|
||||
container_name: rustdesk-api
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- RUSTDESK_API_RUSTDESK_ID_SERVER=192.168.1.66:21116
|
||||
- RUSTDESK_API_RUSTDESK_RELAY_SERVER=192.168.1.66:21117
|
||||
- RUSTDESK_API_RUSTDESK_API_SERVER=http://192.168.1.66:21114
|
||||
- RUSTDESK_API_RUSTDESK_API_SERVER=http://localhost:21114
|
||||
- RUSTDESK_API_RUSTDESK_KEY=123456789
|
||||
ports:
|
||||
- 21114:21114
|
||||
volumes:
|
||||
- ./data/rustdesk/api:/app/data #将数据库挂载出来方便备份
|
||||
# - ./conf:/app/conf # config
|
||||
restart: unless-stopped
|
||||
command: sleep infnite
|
||||
# command: sleep infnite
|
||||
Reference in New Issue
Block a user