Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR for Dockerfile #91

Open
1993alexey opened this issue Oct 9, 2023 · 0 comments
Open

PR for Dockerfile #91

1993alexey opened this issue Oct 9, 2023 · 0 comments

Comments

@1993alexey
Copy link

1993alexey commented Oct 9, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant