Skip to content
Merged
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
26 changes: 26 additions & 0 deletions cmd/joblantern/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# syntax=docker/dockerfile:1.7
#
# joblantern main app — multi-stage build.
FROM golang:1.25-alpine AS build
WORKDIR /src
COPY go.mod go.sum* ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux \
go build -trimpath -ldflags="-s -w" \
-o /out/joblantern ./cmd/joblantern

FROM gcr.io/distroless/static-debian12:nonroot
LABEL org.opencontainers.image.title="joblantern"
LABEL org.opencontainers.image.source="https://github.com/yasserrmd/joblantern"
LABEL org.opencontainers.image.licenses="Apache-2.0"
USER nonroot:nonroot
WORKDIR /app
COPY --from=build /out/joblantern /app/joblantern
ENV JOBLANTERN_ADDR=:8080
EXPOSE 8080
ENTRYPOINT ["/app/joblantern"]
63 changes: 63 additions & 0 deletions cmd/joblantern/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ import (

"github.com/go-chi/chi/v5"
chimiddleware "github.com/go-chi/chi/v5/middleware"
"github.com/modelcontextprotocol/go-sdk/mcp"

"github.com/yasserrmd/joblantern/internal/agent"
"github.com/yasserrmd/joblantern/internal/mcpclient"
"github.com/yasserrmd/joblantern/internal/pattern"
"github.com/yasserrmd/joblantern/internal/risk"
"github.com/yasserrmd/joblantern/internal/transparency"
Expand Down Expand Up @@ -217,9 +219,70 @@ func buildBuiltinSubagents() ([]agent.Subagent, error) {
}}
},
},
buildAddressSubagent(),
}, nil
}

// buildAddressSubagent dials the mcp-address server (if MCP_ADDRESS_URL is
// set) and produces an address.geocoded fact for every submission that
// carries a claimed_address. The dial happens lazily per request so the
// app stays healthy when the MCP server is offline.
func buildAddressSubagent() agent.Subagent {
url := os.Getenv("MCP_ADDRESS_URL")
return &agent.MCPSubagent{
NameStr: "address",
Run_: func(ctx context.Context, sub agent.Submission) []agent.Fact {
if url == "" || sub.ClaimedAddress == "" {
return nil
}
cctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
tr := &mcp.StreamableClientTransport{Endpoint: url, DisableStandaloneSSE: true}
cli, err := mcpclient.Dial(cctx, mcpclient.Config{Server: "joblantern.address", CallTimeout: 8 * time.Second}, tr)
if err != nil {
slog.Warn("mcp-address dial failed", "err", err)
return nil
}
defer func() { _ = cli.Close() }()
var out struct {
Found bool `json:"found"`
Lat float64 `json:"lat"`
Lon float64 `json:"lon"`
DisplayName string `json:"display_name"`
Code string `json:"code"`
}
args := map[string]any{"address": sub.ClaimedAddress}
if sub.Jurisdiction != "" {
args["country_code"] = sub.Jurisdiction
}
if _, err := cli.CallTool(cctx, "verify_address_exists", args, &out); err != nil {
slog.Warn("mcp-address call failed", "err", err)
return nil
}
if !out.Found {
return []agent.Fact{{
Source: "joblantern.address", ToolName: "verify_address_exists",
FactType: "address.not_found",
Value: map[string]any{"address": sub.ClaimedAddress, "code": out.Code},
SupportsRisk: "red",
Weight: 0.5,
}}
}
return []agent.Fact{{
Source: "joblantern.address", ToolName: "verify_address_exists",
FactType: "address.geocoded",
Value: map[string]any{
"lat": out.Lat,
"lon": out.Lon,
"display_name": out.DisplayName,
},
SupportsRisk: "green",
Weight: 0.3,
}}
},
}
}

func probe(addr string) int {
url := "http://127.0.0.1" + addr + "/healthz"
if len(addr) > 0 && addr[0] != ':' {
Expand Down
2 changes: 1 addition & 1 deletion deploy/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Licenses: golang (BSD-3-Clause), distroless (Apache 2.0).

# ---------- Build stage ----------
FROM golang:1.23-alpine AS build
FROM golang:1.25-alpine AS build

WORKDIR /src

Expand Down
81 changes: 81 additions & 0 deletions deploy/docker-compose.smoketest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Joblantern — smoke-test stack with the address sub-agent + map widget.
#
# Brings up postgres, mcp-address (pointed at the public Nominatim service
# for the smoke test), and the main app. Verdicts that include a claimed
# office address get geocoded and the verdict page renders an OSM map
# centred on the result.
#
# Run with:
# docker compose -f deploy/docker-compose.smoketest.yml up -d --build
#
# Host ports chosen to avoid colliding with other dev stacks already
# running on this machine.
name: joblantern-smoke

services:
postgres:
image: postgis/postgis:16-3.4
container_name: joblantern-smoke-postgres
restart: unless-stopped
environment:
POSTGRES_USER: joblantern
POSTGRES_PASSWORD: joblantern
POSTGRES_DB: joblantern
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --locale=C"
ports:
- "5433:5432"
volumes:
- smoke-pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U joblantern -d joblantern"]
interval: 5s
timeout: 3s
retries: 20

mcp-address:
build:
context: ..
dockerfile: cmd/mcp-address/Dockerfile
image: joblantern/mcp-address:smoke
container_name: joblantern-smoke-mcp-address
restart: unless-stopped
command: ["-transport=http", "-addr=:8082"]
environment:
# Public Nominatim — heavily rate-limited (1 req/sec) but fine for
# a one-off smoke test. The User-Agent comes from internal/nominatim.
NOMINATIM_URL: https://nominatim.openstreetmap.org
OVERPASS_URL: https://overpass-api.de/api/interpreter
ports:
- "18082:8082"

joblantern:
build:
context: ..
dockerfile: cmd/joblantern/Dockerfile
image: joblantern/joblantern:smoke
container_name: joblantern-smoke-app
restart: unless-stopped
environment:
JOBLANTERN_ADDR: ":8080"
JOBLANTERN_ENV: development
LOG_LEVEL: info
DATABASE_URL: postgres://joblantern:joblantern@postgres:5432/joblantern?sslmode=disable
SESSION_SECRET: smoke-test-session-secret-not-for-prod-32b=
JOBLANTERN_BADGE_ISSUER: http://localhost:18080
# Dial the in-network mcp-address container.
MCP_ADDRESS_URL: http://mcp-address:8082/
ports:
- "18080:8080"
depends_on:
postgres:
condition: service_healthy
mcp-address:
condition: service_started

volumes:
smoke-pgdata:
name: joblantern-smoke-pgdata

networks:
default:
name: joblantern-smoke-net
7 changes: 5 additions & 2 deletions internal/web/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ func SecurityHeaders(next http.Handler) http.Handler {
h.Set("X-Frame-Options", "DENY")
h.Set("Referrer-Policy", "strict-origin-when-cross-origin")
h.Set("Strict-Transport-Security", "max-age=31536000; includeSubDomains")
// Leaflet needs an inline <script> bootstrap on the verdict page,
// and OSM tile servers are an external img + connect source.
h.Set("Content-Security-Policy",
"default-src 'self'; "+
"img-src 'self' data: https:; "+
"img-src 'self' data: https://*.tile.openstreetmap.org https:; "+
"script-src 'self' 'unsafe-inline'; "+
"style-src 'self' 'unsafe-inline'; "+
"connect-src 'self'; "+
"connect-src 'self' https://*.tile.openstreetmap.org; "+
"frame-ancestors 'none'; "+
"base-uri 'self'")
next.ServeHTTP(w, r)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added internal/web/static/leaflet/images/marker-shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading