Merge remote-tracking branch 'origin/master'

pull/4/head
Max Ehrlicher-Schmidt 4 years ago
commit b5a610f249

@ -5,8 +5,24 @@ language: bash
services: services:
- docker - docker
env:
global:
- DOCKER_CLI_EXPERIMENTAL=enabled
script: script:
- docker login -u="$DOCKER_USER" -p="$DOCKER_PW" https://flotte-docker-registry.spdns.org/ - docker login -u="$DOCKER_USER" -p="$DOCKER_PW" https://flotte-docker-registry.spdns.org/
- docker build -t frontend-server . - sudo chmod o+xr -R /home/travis/.docker
- docker tag frontend-server flotte-docker-registry.spdns.org/frontend-server - sudo chmod o+xr -R /etc/docker
- docker push flotte-docker-registry.spdns.org/frontend-server:latest - docker build -t frontend-server:amd64 . --build-arg ARCH=amd64
- docker build -t frontend-server:arm . --build-arg ARCH=arm
- docker build -t frontend-server:arm64 . --build-arg ARCH=arm64
- docker tag frontend-server:amd64 flotte-docker-registry.spdns.org/frontend-server:amd64
- docker push flotte-docker-registry.spdns.org/frontend-server:amd64
- docker tag frontend-server:arm64 flotte-docker-registry.spdns.org/frontend-server:arm64
- docker push flotte-docker-registry.spdns.org/frontend-server:arm64
- docker tag frontend-server:arm flotte-docker-registry.spdns.org/frontend-server:arm
- docker push flotte-docker-registry.spdns.org/frontend-server:arm
- docker manifest create --amend flotte-docker-registry.spdns.org/frontend-server:latest flotte-docker-registry.spdns.org/frontend-server:arm flotte-docker-registry.spdns.org/frontend-server:arm64 flotte-docker-registry.spdns.org/frontend-server:amd64
- docker manifest annotate flotte-docker-registry.spdns.org/frontend-server:latest flotte-docker-registry.spdns.org/frontend-server:arm --os linux --arch arm --variant v7
- docker manifest annotate flotte-docker-registry.spdns.org/frontend-server:latest flotte-docker-registry.spdns.org/frontend-server:arm64 --os linux --arch arm64 --variant v8
- docker manifest push flotte-docker-registry.spdns.org/frontend-server:latest

@ -9,6 +9,7 @@ COPY . .
RUN ng build --prod --crossOrigin=anonymous RUN ng build --prod --crossOrigin=anonymous
FROM golang:1.13.4-alpine as builder2 FROM golang:1.13.4-alpine as builder2
ARG ARCH=amd64
RUN apk add git RUN apk add git
WORKDIR / WORKDIR /
COPY --from=builder /frontend/dist /dist COPY --from=builder /frontend/dist /dist
@ -16,7 +17,7 @@ RUN go get github.com/rakyll/statik
RUN statik --src=/dist/flotte-frontend RUN statik --src=/dist/flotte-frontend
COPY *.go *.sum *.mod / COPY *.go *.sum *.mod /
COPY vendor /vendor COPY vendor /vendor
RUN CGO_ENABLED=0 GOOS=linux go build --mod=vendor -o frontend_server RUN CGO_ENABLED=0 GOARCH=$ARCH GOOS=linux go build --mod=vendor -o frontend_server
FROM scratch FROM scratch
WORKDIR / WORKDIR /

@ -3,28 +3,26 @@ package main
import ( import (
"log" "log"
"net/http" "net/http"
"strings"
"github.com/rakyll/statik/fs" "github.com/rakyll/statik/fs"
_ "github.com/fLotte-meets-HWR-DB/frontend/statik" _ "github.com/fLotte-meets-HWR-DB/frontend/statik"
) )
func strip(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !strings.Contains(r.URL.Path, ".") {
r.URL.Path = "/"
}
handler.ServeHTTP(w, r)
})
}
func main() { func main() {
statikFS, err := fs.New() statikFS, err := fs.New()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
fserver := http.FileServer(statikFS)
m := http.NewServeMux() m := http.NewServeMux()
m.Handle("/", strip(http.FileServer(statikFS))) m.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if _, err := statikFS.Open(r.URL.Path); err != nil {
r.URL.Path = "/"
}
fserver.ServeHTTP(w, r)
})
log.Fatal(http.ListenAndServe(":8080", m)) log.Fatal(http.ListenAndServe(":8080", m))
} }

Loading…
Cancel
Save