flutter-webrtc / flutter-webrtc-server

A simple WebRTC signaling server for flutter-webrtc.
MIT License
753 stars 304 forks source link

PR for Dockerfile #91

Open 1993alexey opened 11 months ago

1993alexey commented 11 months ago

I wanted to submit a PR, but I don't have access to push new branches. Here is a multi-stage docker build file that takes into account certificates

FROM golang:1.19 AS base

# Set destination for COPY
WORKDIR /app

# Download Go modules
COPY go.mod go.sum ./
RUN go mod download

# Copy the source code
COPY cmd ./cmd/
COPY pkg ./pkg/

# Build
RUN CGO_ENABLE=0 GOOS=linux go build -o bin/webrtc-server -ldflags "-s -w" cmd/server/main.go

# Discard the sourcecode and only keep configs and the executable in the final stage
FROM golang:1.19
WORKDIR /app
COPY --from=base /app/bin/webrtc-server ./bin/webrtc-server
COPY configs/config.ini ./configs/
COPY web ./web/

# Document the running port
EXPOSE 8086

# Run
CMD ["bin/webrtc-server"]

Below are the readme instructions I was planning to add

Docker

  1. CD into the project
  2. Run docker build -t webrtc-server:1.0.0 . to create an image
  3. Run the image
    docker run -p 8086:8086 -v $(pwd)/configs/certs:/app/configs/certs webrtc-server:1.0.0

    P.S. If running on windows, replace $(pwd) with the absolute path