v3: add openssl to prod image and fix deploy command auth via env var (#1011)

* add openssl to prod worker

* make deploy command accept auth token via env var
This commit is contained in:
nicktrn
2024-04-08 19:28:35 +01:00
committed by GitHub
parent f854cb90eb
commit 1c24348f7d
3 changed files with 33 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---
Add openssl to prod worker image and allow passing auth token via env var for deploy
+1
View File
@@ -4,6 +4,7 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
busybox \
dumb-init \
openssl \
&& rm -rf /var/lib/apt/lists/*
# Create and set workdir with appropriate permissions
+27
View File
@@ -72,6 +72,33 @@ export async function login(options?: LoginOptions): Promise<LoginResult> {
intro("Logging in to Trigger.dev");
}
const accessTokenFromEnv = process.env.TRIGGER_ACCESS_TOKEN;
if (accessTokenFromEnv) {
const auth = {
accessToken: accessTokenFromEnv,
apiUrl: process.env.TRIGGER_API_URL ?? "https://api.trigger.dev",
};
const apiClient = new CliApiClient(auth.apiUrl, auth.accessToken);
const userData = await apiClient.whoAmI();
if (!userData.success) {
throw new Error(userData.error);
}
return {
ok: true as const,
profile: options?.profile ?? "default",
userId: userData.data.userId,
email: userData.data.email,
dashboardUrl: userData.data.dashboardUrl,
auth: {
accessToken: auth.accessToken,
apiUrl: auth.apiUrl,
},
};
}
const authConfig = readAuthConfigProfile(options?.profile);
if (authConfig && authConfig.accessToken) {