Skip to content

Commit 15742f1

Browse files
authored
prepare docker image for proper release (#608)
1 parent 4961b34 commit 15742f1

File tree

14 files changed

+162
-108
lines changed

14 files changed

+162
-108
lines changed

.github/workflows/docker-build-web.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
workflow_dispatch:
55
inputs:
66
tag:
7-
description: 'Tag for the Docker image'
7+
description: "Tag for the Docker image"
88
required: false
9-
default: 'latest'
9+
default: "latest"
1010
type: string
1111

1212
jobs:
@@ -23,10 +23,11 @@ jobs:
2323

2424
- name: Set up Docker Buildx
2525
uses: docker/setup-buildx-action@v3
26-
26+
2727
- name: Create .env file
2828
run: |
2929
echo "WEB_URL=http://localhost:3000" > .env
30+
echo "DOCKER_BUILD=true" >> .env
3031
echo "NEXT_PUBLIC_CAP_AWS_BUCKET=capso" >> .env
3132
echo "NEXT_PUBLIC_CAP_AWS_REGION=us-east-1" >> .env
3233
cat .env
@@ -59,4 +60,4 @@ jobs:
5960
cache-to: type=gha,mode=max
6061

6162
- name: Show Docker Images
62-
run: docker images
63+
run: docker images

apps/desktop/src/routes/(window-chrome)/settings/general.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,19 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
259259
<ServerURLSetting
260260
value={settings.serverUrl ?? "https://cap.so"}
261261
onChange={async (v) => {
262+
const url = new URL(v);
263+
const origin = url.origin;
264+
262265
if (
263266
!(await confirm(
264-
`Are you sure you want to change the server URL to '${v}'? You will need to sign in again.`
267+
`Are you sure you want to change the server URL to '${origin}'? You will need to sign in again.`
265268
))
266269
)
267270
return;
268271

269272
await authStore.set(undefined);
270-
await commands.setServerUrl(v);
271-
handleChange("serverUrl", v);
273+
await commands.setServerUrl(origin);
274+
handleChange("serverUrl", origin);
272275
}}
273276
/>
274277
</div>

apps/desktop/src/utils/auth.ts

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,28 @@ async function createLocalServerSession(signal: AbortSignal) {
9595

9696
if (signal.aborted) throw new Error("Sign in aborted");
9797

98-
return paramsValidator.parse({
99-
type: url.searchParams.get("type"),
100-
api_key: url.searchParams.get("api_key"),
101-
user_id: url.searchParams.get("user_id"),
102-
});
98+
const a = [...url.searchParams].reduce((acc, [k, v]) => {
99+
acc[k] = v;
100+
return acc;
101+
}, {} as any);
102+
103+
return paramsValidator.parse(a);
103104
},
104105
};
105106
}
106107

107-
const paramsValidator = z.object({
108-
type: z.literal("api_key"),
109-
api_key: z.string(),
110-
user_id: z.string(),
111-
});
108+
const paramsValidator = z.union([
109+
z.object({
110+
type: z.literal("api_key"),
111+
api_key: z.string(),
112+
user_id: z.string(),
113+
}),
114+
z.object({
115+
token: z.string(),
116+
user_id: z.string(),
117+
expires: z.coerce.number(),
118+
}),
119+
]);
112120

113121
async function createDeepLinkSession(signal: AbortSignal) {
114122
let res: (data: z.infer<typeof paramsValidator>) => void;
@@ -122,11 +130,12 @@ async function createDeepLinkSession(signal: AbortSignal) {
122130
const url = new URL(urlString);
123131

124132
res(
125-
paramsValidator.parse({
126-
type: url.searchParams.get("type"),
127-
api_key: url.searchParams.get("api_key"),
128-
user_id: url.searchParams.get("user_id"),
129-
})
133+
paramsValidator.parse(
134+
[...url.searchParams].reduce((acc, [k, v]) => {
135+
acc[k] = v;
136+
return acc;
137+
}, {} as any)
138+
)
130139
);
131140
}
132141
});
@@ -147,7 +156,10 @@ async function processAuthData(data: z.infer<typeof paramsValidator>) {
147156

148157
const existingAuth = await authStore.get();
149158
await authStore.set({
150-
secret: { api_key: data.api_key },
159+
secret:
160+
"api_key" in data
161+
? { api_key: data.api_key }
162+
: { token: data.token, expires: data.expires },
151163
user_id: data.user_id,
152164
intercom_hash: existingAuth?.intercom_hash ?? "",
153165
plan: null,

apps/web/app/api/selfhosted/migrations/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
22
import { db } from "@cap/database";
33
import { migrate } from "drizzle-orm/mysql2/migrator";
44
import path from "path";
5-
import { serverEnv } from "@cap/env";
5+
import { buildEnv } from "@cap/env";
66

77
const migrations = {
88
run: false,
@@ -16,7 +16,7 @@ export async function POST() {
1616
});
1717
}
1818

19-
const isDockerBuild = serverEnv().DOCKER_BUILD === "true";
19+
const isDockerBuild = buildEnv.NEXT_PUBLIC_DOCKER_BUILD === "true";
2020
if (isDockerBuild) {
2121
try {
2222
console.log("🔍 DB migrations triggered");

0 commit comments

Comments
 (0)