docker:local command
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
frontend:
|
||||
build: .
|
||||
ports:
|
||||
- "8080:80"
|
||||
environment:
|
||||
# Connect to the local SpacetimeDB instance
|
||||
- SPACETIMEDB_URI=ws://localhost:3000
|
||||
- SPACETIMEDB_DB_NAME=my-chat-app
|
||||
depends_on:
|
||||
- module-publisher
|
||||
|
||||
spacetimedb:
|
||||
image: clockworklabs/spacetime:latest
|
||||
ports:
|
||||
- "3000:3000"
|
||||
entrypoint: spacetime start
|
||||
hostname: spacetimedb
|
||||
volumes:
|
||||
- spacetimedb-data:/root/.spacetime
|
||||
|
||||
# A temporary service to publish the module to the local database
|
||||
# on startup, ensuring the schema is always up-to-date.
|
||||
module-publisher:
|
||||
build:
|
||||
context: ./spacetimedb
|
||||
dockerfile: Dockerfile.publish
|
||||
depends_on:
|
||||
- spacetimedb
|
||||
environment:
|
||||
- SPACETIMEDB_URI=http://spacetimedb:3000
|
||||
- SPACETIMEDB_DB_NAME=my-chat-app
|
||||
|
||||
volumes:
|
||||
spacetimedb-data:
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Path to the config file
|
||||
CONFIG_FILE="/usr/share/nginx/html/config.js"
|
||||
|
||||
# Create or overwrite the config file
|
||||
echo "window.__ENV__ = {" > $CONFIG_FILE
|
||||
|
||||
# Append environment variables
|
||||
echo " VITE_SPACETIMEDB_HOST: \"${SPACETIMEDB_URI:-wss://maincloud.spacetimedb.com}\"," >> $CONFIG_FILE
|
||||
echo " VITE_SPACETIMEDB_DB_NAME: \"${SPACETIMEDB_DB_NAME:-zep}\"," >> $CONFIG_FILE
|
||||
echo " VITE_OIDC_AUTHORITY: \"${AUTH_ISSUER:-https://accounts.google.com}\"," >> $CONFIG_FILE
|
||||
echo " VITE_OIDC_CLIENT_ID: \"${AUTH_CLIENT_ID:-REPLACE_ME}\"" >> $CONFIG_FILE
|
||||
|
||||
echo "};" >> $CONFIG_FILE
|
||||
|
||||
# Pass control to the main container command
|
||||
exec "$@"
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# Cache static assets
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|webp|woff|woff2|ttf|eot)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, no-transform";
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
"scripts": {
|
||||
"dev": "vite --host=0.0.0.0",
|
||||
"ssldev": "VITE_USE_SSL=true vite --host=0.0.0.0",
|
||||
"docker:local": "docker compose -f docker-compose.local.yml up --build",
|
||||
"build": "tsc -b && vite build",
|
||||
"format": "prettier . --write --ignore-path ../../.prettierignore",
|
||||
"lint": "eslint .",
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
FROM node:20
|
||||
|
||||
# Install SpacetimeDB CLI
|
||||
RUN apt-get update && apt-get install -y curl && \
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://install.spacetimedb.com | sh -s -- -y
|
||||
|
||||
# Add to path
|
||||
ENV PATH="/root/.local/bin:${PATH}"
|
||||
|
||||
WORKDIR /module
|
||||
COPY . .
|
||||
|
||||
# Run the publish command. We use a shell loop to wait for the DB to be ready.
|
||||
CMD echo "Waiting for SpacetimeDB at ${SPACETIMEDB_URI}..." && \
|
||||
while ! curl -s ${SPACETIMEDB_URI}/api/v1/identity; do sleep 2; done; \
|
||||
echo "Publishing module ${SPACETIMEDB_DB_NAME} to ${SPACETIMEDB_URI}..." && \
|
||||
spacetime server add --url ${SPACETIMEDB_URI} deploy_target && \
|
||||
spacetime publish --server deploy_target --delete-data=on-conflict ${SPACETIMEDB_DB_NAME} -y
|
||||
Reference in New Issue
Block a user