Skip to content

Commit

Permalink
add test DC file, apply app environment, apply registeration state
Browse files Browse the repository at this point in the history
  • Loading branch information
krustowski committed Jul 8, 2024
1 parent 7694624 commit d135a86
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
- name: Deploy prod docker container, recreate container with fresh image.
env:
API_TOKEN: ${{ secrets.API_TOKEN }}
APP_ENVIRONMENT: ${{ vars.APP_ENVIRONMENT }}
APP_PEPPER: ${{ secrets.APP_PEPPER }}
APP_URLS_TRAEFIK: ${{ vars.APP_URLS_TRAEFIK }}
DOCKER_CONTAINER_NAME: ${{ vars.DOCKER_CONTAINER_NAME }}
Expand All @@ -26,6 +27,7 @@ jobs:
MAIL_PORT: ${{ secrets.MAIL_PORT }}
MAIL_SASL_USR: ${{ secrets.MAIL_SASL_USR }}
MAIL_SASL_PWD: ${{ secrets.MAIL_SASL_PWD }}
REGISTERATION_ENABLED: ${{ vars.REGISTERATION_ENABLED }}
REGISTRY: ${{ secrets.REGISTRY }}
VAPID_PUB_KEY: ${{ secrets.VAPID_PUB_KEY }}
VAPID_PRIV_KEY: ${{ secrets.VAPID_PRIV_KEY }}
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ LOKI_URL?=""
APP_PEPPER?=""
API_TOKEN?=""

APP_ENVIRONMENT?=dev
REGISTERATION_ENABLED?=true

VAPID_PUB_KEY?=""
VAPID_PRIV_KEY?=""
VAPID_SUBSCRIBER?=""
Expand Down
31 changes: 25 additions & 6 deletions configs/backend.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
package configs

import (
"os"
)

const (
// Time interval after that a heartbeat event of type 'message' is to be sent to connected clients/subscribers.
HEARTBEAT_SLEEP_TIME = 20
REGISTERATION_ENABLED = false
//REGISTERATION_ENABLED = false
)

/*
* Registeration
*/

var REGISTERATION_ENABLED bool = false

if os.Getenv("REGISTERATION_ENABLED") != "" {
REGISTERATION_ENABLED = os.Getenv("REGISTERATION_ENABLED")
}

/*
* App environment
*/

var APP_ENVIRONMENT string = "dev"

if os.Getenv("APP_ENVIRONMENT") != "" {
APP_ENVIRONMENT = os.Getenv("APP_ENVIRONMENT")
}

/*
* BE data migrations
*/

// Accounts to be ceased from the database inc. their posts.
// You would have to restart backend server for this to apply if you made changes there.
var UserDeletionList []string = []string{
"fred",
"fred2",
"admin",
"alternative",
"Lmao",
"lma0",
}

// This array is used in a procedure's loop to manually unshade listed users.
Expand Down
82 changes: 82 additions & 0 deletions deployments/docker-compose-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#version: '3.9'
name: ${PROJECT_NAME}

networks:
traefik:
name: ${DOCKER_NETWORK_NAME}

volumes:
litter-data:
name: ${DOCKER_VOLUME_DATA_NAME}
litter-pix:
name: ${DOCKER_VOLUME_PIX_NAME}

services:
litter-backend-test:
image: ${DOCKER_IMAGE_TAG}
container_name: ${DOCKER_CONTAINER_NAME}
env_file:
- ../.env
build:
context: ..
dockerfile: build/Dockerfile
args:
APP_NAME: ${APP_NAME}
APP_PEPPER: ${APP_PEPPER}
APP_VERSION: ${APP_VERSION}
DOCKER_INTERNAL_PORT: ${DOCKER_INTERNAL_PORT}
DOCKER_USER: ${DOCKER_USER}
OARCH: ${GOARCH}
GOCACHE: ${GOCACHE}
GOMODCACHE: ${GOMODCACHE}
GOLANG_VERSION: ${GOLANG_VERSION}
TZ: ${TZ}
VAPID_PUB_KEY: ${VAPID_PUB_KEY}
restart: unless-stopped
cpus: 0.3
mem_limit: 128m
mem_reservation: 32m
volumes:
- "litter-data:/opt/data"
- "litter-pix:/opt/pix"
ports:
- "${DOCKER_EXTERNAL_PORT}:${DOCKER_INTERNAL_PORT}"
networks:
- traefik
labels:
- "traefik.http.routers.${APP_NAME}.rule=Host(${APP_URLS_TRAEFIK})"
- "traefik.http.services.${APP_NAME}.loadbalancer.server.port=${DOCKER_INTERNAL_PORT}"
- "traefik.docker.network=${DOCKER_NETWORK_NAME}"
environment:
API_TOKEN: ${API_TOKEN}
APP_PEPPER: ${APP_PEPPER}
VAPID_PUB_KEY: ${VAPID_PUB_KEY}
healthcheck:
#test: ["CMD", "/opt/periodic-dump.sh"]
test: ["CMD", "wget", "--header", "X-Dump-Token: ${API_TOKEN}", "localhost:${DOCKER_INTERNAL_PORT}/api/v1/dump/", "-O", "-", "-S" ]
interval: 5m
timeout: 5s
retries: 3

litter-swagger-test:
image: swaggerapi/swagger-ui
container_name: ${DOCKER_SWAGGER_CONTAINER_NAME}
ports:
- target: 8080
published: ${DOCKER_SWAGGER_EXTERNAL_PORT}
mode: host
protocol: tcp
environment:
BASE_URL: "/docs/"
BASE_PATH: "/api"
SWAGGER_JSON: "/tmp/swagger.json"
networks:
- traefik
volumes:
- "../api/swagger.json:/tmp/swagger.json"
labels:
- "traefik.http.routers.${APP_NAME}-swagger.rule=Host(${APP_URLS_TRAEFIK}) && PathPrefix(`/docs`)"
- "traefik.http.services.${APP_NAME}-swagger.loadbalancer.server.port=8080"
#- "traefik.http.middlewares.${APP_NAME}.stripprefix.prefixes=/docs"
- "traefik.docker.network=${DOCKER_NETWORK_NAME}"

6 changes: 3 additions & 3 deletions pkg/frontend/navbars.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"time"

"go.savla.dev/littr/configs"
"go.savla.dev/littr/pkg/models"

"github.com/maxence-charriere/go-app/v9/pkg/app"
Expand Down Expand Up @@ -325,13 +326,12 @@ func (h *header) Render() app.UI {
app.H4().Class("center-align deep-orange-text").OnClick(h.onClickHeadline).ID("top-header").Body(
app.Span().Body(
app.Text(headerString),
app.If(configs.APP_ENVIRONMENT == "dev",
app.Span().Class("col").Body(
app.Sup().Body(
app.Text(" (beta) "),
),
app.If(strings.Contains(h.pagePath, "flow"),
app.Span().Class("dot"),
),
),
),
),
),
Expand Down

0 comments on commit d135a86

Please sign in to comment.