Moved API URL to environment

This commit is contained in:
DutchEllie 2022-05-14 18:24:19 +02:00
parent 734d9e4e27
commit ba1fae4547
Signed by: DutchEllie
SSH Key Fingerprint: SHA256:dKq6ZSgN5E3Viqrw/+xAdf2VdR6hdRGNyrYqXXwfjTY
8 changed files with 22 additions and 10 deletions

View File

@ -16,8 +16,6 @@ steps:
password:
from_secret: docker_password
repo: dutchellie/proper-website-2
build_args:
- APIURL=https://api.quenten.nl/api/testing
tags:
- dev
- ${DRONE_COMMIT_SHA:0:8}
@ -64,8 +62,6 @@ steps:
password:
from_secret: docker_password
repo: dutchellie/proper-website-2
build_args:
- APIURL=https://api.quenten.nl/api
tags:
- latest
- ${DRONE_COMMIT_SHA:0:8}

View File

@ -31,5 +31,9 @@ spec:
ports:
- name: http
containerPort: 8000
{{- if .Values.containerEnv }}
env: {{ toYaml .Values.containerEnv | nindent 12 }}
{{- end }}

View File

@ -6,6 +6,7 @@ podAnnotations: {}
containerName: newsite
image: dutchellie/proper-website-2:latest
imagePullPolicy: Always
containerEnv: []
service:
name: newsite-service

View File

@ -1,4 +1,7 @@
name: newsite-prod
containerEnv:
- name: APIURL
value: https://api.quenten.nl/api
service:
name: newsite-prod
ingress:

View File

@ -1,4 +1,7 @@
name: newsite-staging
containerEnv:
- name: APIURL
value: https://api.quenten.nl/api/testing
service:
name: newsite-staging
ingress:

View File

@ -3,8 +3,8 @@ ARG APIURL
WORKDIR /project
ADD . /project/
RUN go mod tidy
RUN GOARCH=wasm GOOS=js go build -o web/app.wasm -ldflags="-X 'main.ApiURL=$APIURL'" ./src
RUN go build -o app -ldflags="-X 'main.ApiURL=$APIURL'" ./src
RUN GOARCH=wasm GOOS=js go build -o web/app.wasm ./src
RUN go build -o app ./src
FROM alpine:latest AS staging
RUN apk --no-cache add ca-certificates

View File

@ -10,10 +10,6 @@ import (
"github.com/maxence-charriere/go-app/v9/pkg/app"
)
var (
ApiURL string
)
type Homepage struct {
app.Compo
}

View File

@ -4,6 +4,7 @@ import (
"compress/gzip"
"log"
"net/http"
"os"
"github.com/gorilla/handlers"
"github.com/maxence-charriere/go-app/v9/pkg/app"
@ -15,7 +16,15 @@ import (
// collection *mongo.Collection
//}
var (
ApiURL string
)
func main() {
ApiURL = os.Getenv("APIURL")
if ApiURL == "" {
log.Fatalln("Unable to get API URL from environment variables!")
}
homepage := NewHomepage()
aboutpage := NewAboutPage()
galaxiespage := NewGalaxiesPage()