Skip to content

Commit 166e289

Browse files
authored
Merge pull request #174 from ShipSecAI/betterclever/prod-image-setup
feat: Easy self-hosting with just prod start-latest
2 parents 11525ee + 4c3a50a commit 166e289

File tree

5 files changed

+108
-17
lines changed

5 files changed

+108
-17
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ jobs:
118118
tags: ${{ steps.tags.outputs.backend_tags }}
119119
build-args: |
120120
VITE_GIT_SHA=${{ steps.git_sha.outputs.sha }}
121+
POSTHOG_API_KEY=${{ secrets.POSTHOG_API_KEY }}
122+
POSTHOG_HOST=${{ secrets.POSTHOG_HOST }}
121123
cache-from: type=gha
122124
cache-to: type=gha,mode=max
123125

@@ -131,6 +133,8 @@ jobs:
131133
tags: ${{ steps.tags.outputs.worker_tags }}
132134
build-args: |
133135
VITE_GIT_SHA=${{ steps.git_sha.outputs.sha }}
136+
POSTHOG_API_KEY=${{ secrets.POSTHOG_API_KEY }}
137+
POSTHOG_HOST=${{ secrets.POSTHOG_HOST }}
134138
cache-from: type=gha
135139
cache-to: type=gha,mode=max
136140

@@ -146,6 +150,8 @@ jobs:
146150
VITE_GIT_SHA=${{ steps.git_sha.outputs.sha }}
147151
VITE_PUBLIC_POSTHOG_KEY=${{ secrets.POSTHOG_API_KEY }}
148152
VITE_PUBLIC_POSTHOG_HOST=${{ secrets.POSTHOG_HOST }}
153+
POSTHOG_API_KEY=${{ secrets.POSTHOG_API_KEY }}
154+
POSTHOG_HOST=${{ secrets.POSTHOG_HOST }}
149155
cache-from: type=gha
150156
cache-to: type=gha,mode=max
151157

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ FROM base AS backend
4040
# Switch to user
4141
USER shipsec
4242

43+
# PostHog analytics (optional)
44+
ARG POSTHOG_API_KEY=""
45+
ARG POSTHOG_HOST=""
46+
ENV POSTHOG_API_KEY=${POSTHOG_API_KEY}
47+
ENV POSTHOG_HOST=${POSTHOG_HOST}
48+
4349
# Set working directory for backend
4450
WORKDIR /app/backend
4551

@@ -57,6 +63,12 @@ FROM base AS worker
5763
# Switch to user
5864
USER shipsec
5965

66+
# PostHog analytics (optional)
67+
ARG POSTHOG_API_KEY=""
68+
ARG POSTHOG_HOST=""
69+
ENV POSTHOG_API_KEY=${POSTHOG_API_KEY}
70+
ENV POSTHOG_HOST=${POSTHOG_HOST}
71+
6072
# Set working directory for worker
6173
WORKDIR /app/worker
6274

README.md

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,54 @@ Get started with ShipSec Studio in minutes:
6161
3. **Run a scan** with pre-built components like Subfinder, Nuclei, or HTTPx
6262
4. **View results** in real-time as the workflow executes
6363

64-
### Option 2: Run Locally
64+
### Option 2: Self-Host with Docker (Recommended)
65+
66+
The easiest way to run ShipSec Studio on your own infrastructure:
67+
68+
#### Prerequisites
69+
70+
- **[docker](https://www.docker.com/)** - For running the application and security components
71+
- **[just](https://github.com/casey/just)** - Command runner for simplified workflows
72+
- **curl** and **jq** - For fetching release information
73+
74+
#### Quick Start
75+
76+
```bash
77+
# Clone the repository
78+
git clone https://github.com/ShipSecAI/studio.git
79+
cd studio
80+
81+
# Download the latest release and start
82+
just prod start-latest
83+
84+
# Visit http://localhost:8090 to access ShipSec Studio
85+
```
86+
87+
This command automatically:
88+
- Fetches the latest release version from GitHub
89+
- Pulls pre-built Docker images from GHCR
90+
- Starts the full stack (frontend, backend, worker, and infrastructure)
91+
92+
#### Other Commands
93+
94+
```bash
95+
just prod stop # Stop the environment
96+
just prod logs # View logs
97+
just prod status # Check status
98+
just prod clean # Remove all data
99+
```
100+
101+
### Option 3: Development Setup
102+
103+
For contributors who want to modify the source code:
65104

66105
#### Prerequisites
67106

68107
- **[bun.sh](https://bun.sh)** - Fast JavaScript runtime and package manager
69108
- **[docker](https://www.docker.com/)** - For running security components in isolated containers
70109
- **[just](https://github.com/casey/just)** - Command runner for simplified development workflows
71110

72-
#### Quick Setup with `just` (Recommended)
111+
#### Setup
73112

74113
```bash
75114
# Clone the repository
@@ -79,7 +118,7 @@ cd studio
79118
# Initialize (installs dependencies and creates environment files)
80119
just init
81120

82-
# Start development environment
121+
# Start development environment with hot-reload
83122
just dev
84123

85124
# Visit http://localhost:5173 to access ShipSec Studio

docker/docker-compose.full.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ services:
167167
restart: unless-stopped
168168

169169
backend:
170-
image: ghcr.io/shipsecai/studio-backend:latest
170+
image: ghcr.io/shipsecai/studio-backend:${SHIPSEC_TAG:-latest}
171171
build:
172172
context: ..
173173
dockerfile: Dockerfile
@@ -198,10 +198,8 @@ services:
198198
- AUTH_PROVIDER=local
199199
- CLERK_PUBLISHABLE_KEY=
200200
- CLERK_SECRET_KEY=
201-
# PostHog analytics (baked into Docker images)
202-
- POSTHOG_API_KEY=${POSTHOG_API_KEY:-}
203-
- POSTHOG_HOST=${POSTHOG_HOST:-}
204-
- DISABLE_ANALYTICS=${DISABLE_ANALYTICS:-}
201+
# Set to 'true' to disable analytics
202+
- DISABLE_ANALYTICS=${DISABLE_ANALYTICS:-false}
205203
ports:
206204
- "3211:3211"
207205
depends_on:
@@ -214,9 +212,9 @@ services:
214212
redis:
215213
condition: service_healthy
216214
restart: unless-stopped
217-
215+
218216
frontend:
219-
image: ghcr.io/shipsecai/studio-frontend:latest
217+
image: ghcr.io/shipsecai/studio-frontend:${SHIPSEC_TAG:-latest}
220218
build:
221219
context: ..
222220
dockerfile: Dockerfile
@@ -237,11 +235,6 @@ services:
237235
- VITE_AUTH_PROVIDER=clerk
238236
- VITE_DEFAULT_ORG_ID=local-dev
239237
- VITE_CLERK_PUBLISHABLE_KEY=
240-
# PostHog analytics (optional). Set in your shell or a .env file next to this compose.
241-
# If unset, the app disables analytics at runtime.
242-
- VITE_PUBLIC_POSTHOG_KEY=${VITE_PUBLIC_POSTHOG_KEY:-}
243-
- VITE_PUBLIC_POSTHOG_HOST=${VITE_PUBLIC_POSTHOG_HOST:-}
244-
- VITE_DISABLE_ANALYTICS=${VITE_DISABLE_ANALYTICS:-}
245238
ports:
246239
- "8090:8080"
247240
depends_on:
@@ -254,7 +247,7 @@ services:
254247
retries: 5
255248

256249
worker:
257-
image: ghcr.io/shipsecai/studio-worker:latest
250+
image: ghcr.io/shipsecai/studio-worker:${SHIPSEC_TAG:-latest}
258251
build:
259252
context: ..
260253
dockerfile: Dockerfile

justfile

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,44 @@ prod action="start":
156156
docker system prune -f
157157
echo "✅ Production cleaned"
158158
;;
159+
start-latest)
160+
echo "🔍 Fetching latest release information from GitHub API..."
161+
if ! command -v curl &> /dev/null || ! command -v jq &> /dev/null; then
162+
echo "❌ curl or jq is not installed. Please install them first."
163+
exit 1
164+
fi
165+
166+
LATEST_TAG=$(curl -s https://api.github.com/repos/ShipSecAI/studio/releases | jq -r '.[0].tag_name')
167+
168+
# Strip leading 'v' if present (v0.1-rc2 -> 0.1-rc2)
169+
LATEST_TAG="${LATEST_TAG#v}"
170+
171+
if [ "$LATEST_TAG" == "null" ] || [ -z "$LATEST_TAG" ]; then
172+
echo "❌ Could not find any releases. Please check the repository at https://github.com/ShipSecAI/studio/releases"
173+
exit 1
174+
fi
175+
176+
echo "📦 Found latest release: $LATEST_TAG"
177+
178+
echo "📥 Pulling matching images from GHCR..."
179+
docker pull ghcr.io/shipsecai/studio-backend:$LATEST_TAG
180+
docker pull ghcr.io/shipsecai/studio-frontend:$LATEST_TAG
181+
docker pull ghcr.io/shipsecai/studio-worker:$LATEST_TAG
182+
183+
echo "🚀 Starting production environment with version $LATEST_TAG..."
184+
export SHIPSEC_TAG=$LATEST_TAG
185+
docker compose -f docker/docker-compose.full.yml up -d
186+
187+
echo ""
188+
echo "✅ ShipSec Studio $LATEST_TAG ready"
189+
echo " Frontend: http://localhost:8090"
190+
echo " Backend: http://localhost:3211"
191+
echo " Temporal UI: http://localhost:8081"
192+
echo ""
193+
echo "💡 Note: Using images tagged as $LATEST_TAG"
194+
;;
159195
*)
160-
echo "Usage: just prod [start|stop|build|logs|status|clean]"
196+
echo "Usage: just prod [start|start-latest|stop|build|logs|status|clean]"
161197
;;
162198
esac
163199

@@ -219,11 +255,15 @@ prod-images action="start":
219255

220256
DOCKER_BUILDKIT=1 docker build \
221257
--target backend \
258+
--build-arg POSTHOG_API_KEY=$POSTHOG_API_KEY \
259+
--build-arg POSTHOG_HOST=$POSTHOG_HOST \
222260
-t ghcr.io/shipsecai/studio-backend:latest \
223261
.
224262

225263
DOCKER_BUILDKIT=1 docker build \
226264
--target worker \
265+
--build-arg POSTHOG_API_KEY=$POSTHOG_API_KEY \
266+
--build-arg POSTHOG_HOST=$POSTHOG_HOST \
227267
-t ghcr.io/shipsecai/studio-worker:latest \
228268
.
229269

@@ -325,6 +365,7 @@ help:
325365
@echo "Production (Docker):"
326366
@echo " just prod Start with cached images"
327367
@echo " just prod build Rebuild and start"
368+
@echo " just prod start-latest Download latest release and start"
328369
@echo " just prod stop Stop production"
329370
@echo " just prod logs View production logs"
330371
@echo " just prod status Check production status"

0 commit comments

Comments
 (0)