Greg-House commited on
Commit
fcd7f14
·
verified ·
1 Parent(s): c4ac359

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +52 -0
Dockerfile ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # --- Stage 1: Build remotemoe ---
2
+ FROM golang:1.21-alpine AS builder
3
+
4
+ # Install git
5
+ RUN apk add --no-cache git
6
+
7
+ WORKDIR /app
8
+
9
+ # Copy dependency files and download
10
+ COPY go.mod go.sum ./
11
+ RUN go mod download
12
+
13
+ # Copy source and build
14
+ COPY . .
15
+ # Build statically
16
+ RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o remotemoe main.go
17
+
18
+ # --- Stage 2: Runtime ---
19
+ FROM alpine:latest
20
+
21
+ # Install sslh (multiplexer) and ca-certificates
22
+ RUN apk add --no-cache sslh ca-certificates
23
+
24
+ # Create a non-root user with ID 1000
25
+ RUN adduser -D -u 1000 appuser
26
+
27
+ WORKDIR /home/appuser
28
+
29
+ # Copy the binary
30
+ COPY --from=builder /app/remotemoe .
31
+
32
+ # Create a start script
33
+ RUN echo "#!/bin/sh" > start.sh && \
34
+ echo "echo 'Starting remotemoe...'" >> start.sh && \
35
+ echo "./remotemoe --ssh-addr :2222 --http-addr :8080 &" >> start.sh && \
36
+ echo "echo 'Waiting for remotemoe to initialize...'" >> start.sh && \
37
+ echo "sleep 2" >> start.sh && \
38
+ echo "echo 'Starting sslh on port 7860...'" >> start.sh && \
39
+ echo "exec sslh -f -v -p 0.0.0.0:7860 --ssh 127.0.0.1:2222 --http 127.0.0.1:8080" >> start.sh && \
40
+ chmod +x start.sh
41
+
42
+ # Fix permissions so the non-root user can write SSH keys and logs
43
+ RUN chown -R appuser:appuser /home/appuser
44
+
45
+ # Switch to non-root user
46
+ USER appuser
47
+
48
+ # Expose the HF App Port
49
+ EXPOSE 7860
50
+
51
+ # Run the script
52
+ CMD ["./start.sh"]