Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .env.run-docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
POSTGRES_USER = "vlm"
POSTGRES_PASSWORD = "vlm"
POSTGRES_HOST = "localhost"
POSTGRES_PORT = 15432
POSTGRES_DB = "vlm"

REDIS_HOST="localhost"
REDIS_PORT=6379

PROD_ID="prod_RtTisr8wmgg9gJ"
DISCOUNT_ID="special-launch-price"
DISCOUNT_NAME="special-launch-price"
FREE_SANITY_ID="831faa5c-dbbd-4d9a-9b1a-1cd661b61e40"
PRO_SANITY_ID="21bfee77-bcaf-4c93-9447-14ffa1343a31"
PREMIUM_SANITY_ID="78bd43f5-ad04-4d76-8374-23b35ff6dc6a"
DATABASE_URL="postgresql+asyncpg://vlm:vlm@localhost:15432/vlm"
STRIPE_API_KEY="sk_test_51PC03bFjhkSGAqrA4yCXKDmA8NN1DV2hkLu9ixpBYSGdQ86SXqlFEdz0Bsoo067s5CemI1TPmQTgm72bTMSwMtNs00JCAWNapu"
ENABLE_DISCOUNT=True
DISCOUNT_MONTHLY_ID="offer-discount-test-monthly"
DISCOUNT_YEARLY_ID="offer-discount-test-yearly"
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
SHELL := /bin/bash

SERVICE_NAME=virtual-lab-manager
GIT_COMMIT := $(shell git rev-parse --short=8 HEAD)
VLAB_SVC_TAG ?= $(GIT_COMMIT)
VLAB_SVC_NAME ?= $(SERVICE_NAME)

export VLAB_SVC_TAG
export VLAB_SVC_NAME


define HELPTEXT
Usage: make COMMAND
Expand Down Expand Up @@ -91,4 +98,14 @@ migration: ## Create or update the alembic migration
poetry run alembic revision --autogenerate -m "$(MESSAGE)"

tiers:
poetry run populate-tiers
poetry run populate-tiers


build-tagged:
docker build -t $(VLAB_SVC_NAME):$(VLAB_SVC_TAG) .

up-tagged:
docker-compose -f docker-compose.remote.yml up

down-tagged:
docker-compose -f docker-compose.remote.yml down --remove-orphans --volumes
1 change: 0 additions & 1 deletion docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ services:
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1


stripe-cli:
image: stripe/stripe-cli:latest
container_name: stripe
Expand Down
135 changes: 135 additions & 0 deletions docker-compose.remote.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
volumes:
keycloak_data: {}
vlm_data: {}
redis-data: {}


services:
keycloak-db:
image: postgres:latest
container_name: vlab-keycloak-db
environment:
POSTGRES_USER: keycloak
POSTGRES_PASSWORD: keycloak
POSTGRES_DB: keycloak
healthcheck:
test: ["CMD-SHELL", "pg_isready -U keycloak"]
interval: 10s
timeout: 5s
retries: 3
restart: unless-stopped
volumes:
- keycloak_data:/var/lib/postgresql/data

keycloak:
image: quay.io/keycloak/keycloak:24.0
container_name: vlab-keycloak
environment:
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: admin
DB_VENDOR: postgres
DB_ADDR: keycloak-db
DB_DATABASE: keycloak
DB_USER: keycloak
DB_PASSWORD: keycloak
depends_on:
keycloak-db:
condition: service_healthy
command:
- start-dev
- --http-port=9090
- --hostname=keycloak
- --hostname-port=9090
- --hostname-strict-backchannel=true
- --import-realm
ports:
- "9090:9090"
volumes:
- ./env-prep/realm-export.json:/opt/keycloak/data/import/realm-import.json


virtual-lab-db:
image: postgres:latest
container_name: vlab-db
environment:
POSTGRES_USER: vlm
POSTGRES_PASSWORD: vlm
POSTGRES_DB: vlm
command: postgres -p 5433
ports:
- 15432:5433
healthcheck:
test: ["CMD-SHELL", "pg_isready -U vlm"]
interval: 10s
timeout: 5s
retries: 3
restart: unless-stopped
volumes:
- vlm_data:/var/lib/postgresql/data

virtual-lab-mailpit:
image: axllent/mailpit
container_name: vlab-mailpit
restart: always
volumes:
- ./env-prep/email-data:/email-data
ports:
- 8025:8025 # UI to see sent emails
- 1025:1025 # test smtp server
environment:
MP_MAX_MESSAGES: 5000
MP_DATA_FILE: /email-data/mailpit.db
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1

virtual-lab-stripe-cli:
image: stripe/stripe-cli:latest
container_name: vlab-stripe-cli
environment:
STRIPE_CLI_TELEMETRY_OPTOUT: 1
STRIPE_API_KEY: ${STRIPE_SECRET_KEY}
STRIPE_DEVICE_NAME: ${STRIPE_DEVICE_NAME}
entrypoint:
- '/bin/sh'
- '-c'
- stripe listen --forward-to http://host.docker.internal:8000/payments/webhook
network_mode: host
extra_hosts:
- "host.docker.internal:host-gateway"
- "172.17.0.1:host-gateway"
virtual-lab-redis:
image: "redis:7.2.3"
command: redis-server /usr/local/etc/redis/redis.conf
container_name: vlab-redis
volumes:
- ./env-prep/init/redis.conf:/usr/local/etc/redis/redis.conf
ports:
- "6379:6379"
healthcheck:
test: [ "CMD", "redis-cli","ping" ]
interval: 10s
retries: 5
start_period: 5s
timeout: 10s

virtual-lab-manager:
build:
dockerfile: Dockerfile
image: ${VLAB_SVC_NAME}:${VLAB_SVC_TAG}
container_name: ${VLAB_SVC_NAME}
depends_on:
- keycloak
- virtual-lab-mailpit
- virtual-lab-stripe-cli
- virtual-lab-db
- virtual-lab-redis
environment:
- VLAB_SVC_TAG=${VLAB_SVC_TAG}
- VLAB_SVC_NAME=${VLAB_SVC_NAME}
- POSTGRES_PORT=5433
- POSTGRES_HOST=virtual-lab-db
- KC_SERVER_URI=http://keycloak:9090
- REDIS_HOST=redis
- REDIS_PORT=6379
ports:
- "8200:8000"