This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.9 AS builder | |
WORKDIR / | |
# copy everything from host folder into this image | |
COPY . . | |
# Build binary and place it at /main | |
RUN go build -o /main | |
# Initiate the Second Build stage | |
FROM scratch | |
COPY --from=builder /main /main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "log" | |
func main() { | |
log.Println("Hello from Scratch") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.9 AS builder | |
# Build our software binary | |
FROM scratch | |
# Here we will copy the binary from the Builder Image into this scratch Container | |
COPY --from=builder path/on/builder path/on/scratch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// setupAPI will start all Routes and their Handlers | |
func setupAPI() { | |
// Create a Manager instance used to handle WebSocket Connections | |
manager := NewManager() | |
// Serve the ./frontend directory at Route / | |
http.Handle("/", http.FileServer(http.Dir("./frontend"))) | |
http.HandleFunc("/ws", manager.serveWS) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/http" | |
"github.com/gorilla/websocket" | |
) | |
var ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Once the website loads, we want to apply listeners and connect to websocket | |
* */ | |
window.onload = function () { | |
// Apply our listener functions to the submit event on both forms | |
// we do it this way to avoid redirects | |
document.getElementById("chatroom-selection").onsubmit = changeChatRoom; | |
document.getElementById("chatroom-message").onsubmit = sendMessage; | |
// Check if the browser supports WebSocket |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | |
<title>PP - Websockets</title> | |
</head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/http" | |
) | |
func main() { | |
setupAPI() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker build -t demo/ffmpeg . | |
# Run the container on the demo video and output into mounted share | |
docker run -v $PWD/data:/shared demo/ffmpeg -i /videos/big_buck_bunny_720p_1mb.mp4 -filter:v "setpts=PTS/60" /shared/output.mkv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu | |
RUN apt-get -y update &&\ | |
apt-get -y install ffmpeg &&\ | |
mkdir /videos | |
ADD https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4 /videos | |
ENTRYPOINT ["ffmpeg"] |