Skip to content

Commit 17ccbc3

Browse files
committed
fix docker build
1 parent 1a4bf10 commit 17ccbc3

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

apps/web/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker.io/docker/dockerfile:1
22

3-
FROM node:20-alpine AS base
3+
FROM node:22-alpine AS base
44
RUN corepack enable
55

66
FROM base AS builder

apps/web/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { getCurrentUser } from "@cap/database/auth/session";
88
import { buildEnv, serverEnv } from "@cap/env";
99
import { S3_BUCKET_URL } from "@cap/utils";
1010
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
11-
import crypto from "crypto";
11+
import crypto from "node:crypto";
1212
import type { Metadata } from "next";
1313
import { PropsWithChildren } from "react";
1414
import { AuthProvider } from "./AuthProvider";

apps/web/instrumentation.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// It is not suitable (a.k.a DEADLY) for serverless environments where the server will be restarted on each request.
33

44
import { serverEnv } from "@cap/env";
5-
import { createS3Client } from "./utils/s3";
65
import {
76
BucketAlreadyOwnedByYou,
87
CreateBucketCommand,
98
PutBucketPolicyCommand,
9+
S3Client,
1010
} from "@aws-sdk/client-s3";
1111

1212
export async function register() {
@@ -61,7 +61,15 @@ export async function register() {
6161
}
6262

6363
async function createS3Bucket() {
64-
const [s3Client] = await createS3Client();
64+
const s3Client = new S3Client({
65+
endpoint: serverEnv().CAP_AWS_ENDPOINT,
66+
region: serverEnv().CAP_AWS_REGION,
67+
credentials: {
68+
accessKeyId: serverEnv().CAP_AWS_ACCESS_KEY ?? "",
69+
secretAccessKey: serverEnv().CAP_AWS_SECRET_KEY ?? "",
70+
},
71+
forcePathStyle: serverEnv().S3_PATH_STYLE,
72+
});
6573

6674
await s3Client
6775
.send(new CreateBucketCommand({ Bucket: serverEnv().CAP_AWS_BUCKET }))

apps/web/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@
110110
"tailwindcss": "^3",
111111
"typescript": "^5.8.3"
112112
},
113+
"browser": {
114+
"crypto": false
115+
},
113116
"engines": {
114117
"node": "20"
115118
}
116-
}
119+
}

apps/web/utils/s3.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import type { s3Buckets } from "@cap/database/schema";
1010
import type { InferSelectModel } from "drizzle-orm";
1111
import { decrypt } from "@cap/database/crypto";
12-
import { buildEnv, serverEnv } from "@cap/env";
12+
import { serverEnv } from "@cap/env";
1313
import * as S3Presigner from "@aws-sdk/s3-request-presigner";
1414
import * as CloudFrontPresigner from "@aws-sdk/cloudfront-signer";
1515
import { S3_BUCKET_URL } from "@cap/utils";

packages/database/crypto.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { serverEnv } from "@cap/env";
2-
import { timingSafeEqual } from "crypto";
2+
import { timingSafeEqual } from "node:crypto";
33

44
const ALGORITHM = { name: "AES-GCM", length: 256 };
55
const IV_LENGTH = 12;
@@ -162,7 +162,10 @@ export async function hashPassword(password: string): Promise<string> {
162162
return result.toString("base64");
163163
}
164164

165-
export async function verifyPassword(stored: string, password: string): Promise<boolean> {
165+
export async function verifyPassword(
166+
stored: string,
167+
password: string
168+
): Promise<boolean> {
166169
if (!stored || !password) return false;
167170

168171
const data = Buffer.from(stored, "base64");

0 commit comments

Comments
 (0)