mirror of
https://github.com/lejianwen/rustdesk-api.git
synced 2026-02-17 14:04:51 +08:00
optimize docker
This commit is contained in:
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
docker-compose.yaml
|
||||||
|
Dcokerfile
|
||||||
|
Dcokerfile.dev
|
||||||
|
data
|
||||||
42
Dockerfile.dev
Normal file
42
Dockerfile.dev
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# Use build arguments for Go version and architecture
|
||||||
|
ARG GO_VERSION=1.23.2
|
||||||
|
ARG BUILDARCH
|
||||||
|
|
||||||
|
# Stage 1: Build the Go application with swag
|
||||||
|
FROM golang:${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
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
#run the build script
|
||||||
|
RUN chmod +x build.sh && ./build.sh
|
||||||
|
|
||||||
|
# Stage 2: Prepare the final image
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
# Set up working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install necessary dependencies
|
||||||
|
RUN apk add --no-cache tzdata file
|
||||||
|
|
||||||
|
# Copy the built application from the builder stage
|
||||||
|
COPY --from=builder /app/release /app/
|
||||||
|
|
||||||
|
# Ensure the binary is correctly built
|
||||||
|
RUN file /app/apimain
|
||||||
|
|
||||||
|
# Set up a volume for persistent data
|
||||||
|
VOLUME /app/data
|
||||||
|
|
||||||
|
# Expose the necessary port
|
||||||
|
EXPOSE 21114
|
||||||
|
|
||||||
|
# Define the command to run the application
|
||||||
|
CMD ["app/apimain"]
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
rustdesk-api:
|
rustdesk-api:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.dev
|
||||||
image: lejianwen/rustdesk-api
|
image: lejianwen/rustdesk-api
|
||||||
container_name: rustdesk-api
|
container_name: rustdesk-api
|
||||||
environment:
|
environment:
|
||||||
@@ -11,5 +14,6 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 21114:21114
|
- 21114:21114
|
||||||
volumes:
|
volumes:
|
||||||
- /data/rustdesk/api:/app/data #将数据库挂载出来方便备份
|
- ./data/rustdesk/api:/app/data #将数据库挂载出来方便备份
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
command: sleep infnite
|
||||||
Reference in New Issue
Block a user