Skip to content

Commit d5a0b22

Browse files
committed
Merge branch 'docker' into docker-prod
2 parents 0c2061f + 909e0f1 commit d5a0b22

File tree

12 files changed

+103
-61
lines changed

12 files changed

+103
-61
lines changed

.github/workflows/build_server.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
else
2323
echo "ENV_TAG=staging" >> $GITHUB_OUTPUT
2424
echo "COMPOSE_FILE=docker-compose.staging.yml" >> $GITHUB_OUTPUT
25-
echo "STACK_NAME=streameth-staging" >> $GITHUB_OUTPUT
25+
echo "STACK_NAME=staging" >> $GITHUB_OUTPUT
2626
fi
2727
build-and-push-images:
2828
needs: prepare-env

.github/workflows/clean_caches.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: cleanup caches
2+
on:
3+
workflow_dispatch: # Adding manual trigger option
4+
5+
jobs:
6+
cleanup:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Cleanup all caches
10+
run: |
11+
if [ "${{ github.event_name }}" == "pull_request" ]; then
12+
# For pull request events, clean specific PR branch caches
13+
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
14+
echo "Cleaning caches for PR branch: $BRANCH"
15+
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
16+
else
17+
# For manual dispatch, clean all caches
18+
echo "Cleaning all repository caches"
19+
cacheKeysForPR=$(gh cache list --limit 100 --json id --jq '.[].id')
20+
fi
21+
22+
## Setting this to not fail the workflow while deleting cache keys.
23+
set +e
24+
echo "Deleting caches..."
25+
for cacheKey in $cacheKeysForPR
26+
do
27+
gh cache delete $cacheKey --confirm
28+
done
29+
echo "Done"
30+
env:
31+
GH_TOKEN: ${{ secrets.TOKEN }}
32+
GH_REPO: ${{ github.repository }}

docker-compose.prod.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ x-common-environment: &common-environment
1212
DB_NAME: streameth-prod
1313
JWT_SECRET_FILE: /run/secrets/jwt-secret
1414
JWT_EXPIRY: 30d
15-
CORS_ORIGIN: "[]"
15+
CORS_ORIGIN: "*"
1616
CORS_CREDENTIALS: "true"
1717
CORS_PROXY_URL: ""
1818
LIVEPEER_API_KEY_FILE: /run/secrets/prod-livepeer-api-key
@@ -43,7 +43,7 @@ x-common-environment: &common-environment
4343
REMOTION_WEBHOOK_SECRET_FILE: /run/secrets/remotion-webhook-secret
4444
REMOTION_ID: pebs
4545
REMOTION_SITE_NAME: https://streameth.org
46-
REMOTION_WEBHOOK_URL: https://prod.api.streameth.org/remotion-webhook
46+
REMOTION_WEBHOOK_URL: https://prod.api.streameth.org/webhook/remotion
4747
PIPEDREAM_AUTH_TOKEN_FILE: /run/secrets/pipedream-auth-token
4848
DEVCON_UPLOAD_ENDPOINT_FILE: /run/secrets/devcon-upload-endpoint
4949
LOG_DIR: logs
@@ -212,11 +212,11 @@ services:
212212
labels:
213213
- "traefik.enable=true"
214214
- "traefik.docker.network=traefik-public"
215-
- "traefik.http.routers.reel-creator-prod.rule=Host(`prod.remotion.streameth.org`)"
215+
- "traefik.http.routers.reel-creator-prod.rule=Host(`prod.api.streameth.org`)"
216216
- "traefik.http.routers.reel-creator-prod.service=reel-creator-prod"
217217
- "traefik.http.routers.reel-creator-prod.tls=true"
218218
- "traefik.http.routers.reel-creator-prod.tls.certresolver=myresolver"
219-
- "traefik.http.services.reel-creator-prod.loadbalancer.server.port=4000"
219+
- "traefik.http.services.reel-creator-prod.loadbalancer.server.port=3000"
220220
secrets:
221221
- aws-access-key
222222
- aws-secret-key
@@ -231,7 +231,6 @@ services:
231231
- redis
232232
environment:
233233
<<: *common-environment
234-
REMOTION_WEBHOOK_URL: https://prod.api.streameth.org/remotion-webhook
235234
deploy:
236235
<<: *common-deploy
237236
mode: replicated

docker-compose.router.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ services:
2828
- "traefik.http.routers.to-staging.service=staging-server"
2929
- "traefik.http.routers.to-staging.tls=true"
3030
- "traefik.http.routers.to-staging.tls.certresolver=myresolver"
31-
# CORS middleware
31+
# CORS middleware for staging
3232
- "traefik.http.routers.to-staging.middlewares=to-staging-cors"
3333
- "traefik.http.middlewares.to-staging-cors.headers.accesscontrolalloworiginlist=*"
3434
- "traefik.http.middlewares.to-staging-cors.headers.accesscontrolalloworiginlist=http://localhost:3000,http://localhost,https://staging.api.streameth.org"
@@ -41,6 +41,14 @@ services:
4141
- "traefik.http.routers.to-prod.service=prod-server"
4242
- "traefik.http.routers.to-prod.tls=true"
4343
- "traefik.http.routers.to-prod.tls.certresolver=myresolver"
44+
# CORS middleware for production
45+
- "traefik.http.routers.to-prod.middlewares=to-prod-cors"
46+
- "traefik.http.middlewares.to-prod-cors.headers.accesscontrolalloworiginlist=*"
47+
- "traefik.http.middlewares.to-prod-cors.headers.accesscontrolalloworiginlist=http://localhost:3000,http://localhost,https://prod.api.streameth.org"
48+
- "traefik.http.middlewares.to-prod-cors.headers.accesscontrolallowheaders=*"
49+
- "traefik.http.middlewares.to-prod-cors.headers.accesscontrolallowmethods=GET,OPTIONS,PUT,POST,DELETE,PATCH"
50+
- "traefik.http.middlewares.to-prod-cors.headers.accesscontrolmaxage=100"
51+
- "traefik.http.middlewares.to-prod-cors.headers.addvaryheader=true"
4452
ports:
4553
- "80:80"
4654
- "443:443"

docker-compose.staging.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ x-common-environment: &common-environment
77
BASE_URL: https://staging.api.streameth.org
88
PLAYER_URL: https://staging.player.streameth.org
99
DB_PASSWORD_FILE: /run/secrets/db-password
10-
DB_HOST: streameth-staging_mongodb
10+
DB_HOST: staging_mongodb
1111
DB_USER: root
1212
DB_NAME: streameth-staging
1313
JWT_SECRET_FILE: /run/secrets/jwt-secret
@@ -43,7 +43,7 @@ x-common-environment: &common-environment
4343
REMOTION_WEBHOOK_SECRET_FILE: /run/secrets/remotion-webhook-secret
4444
REMOTION_ID: pebs
4545
REMOTION_SITE_NAME: rendering-engine
46-
REMOTION_WEBHOOK_URL: https://staging.api.streameth.org/remotion-webhook
46+
REMOTION_WEBHOOK_URL: https://staging.api.streameth.org/webhook/remotion
4747
PIPEDREAM_AUTH_TOKEN_FILE: /run/secrets/pipedream-auth-token
4848
DEVCON_UPLOAD_ENDPOINT_FILE: /run/secrets/devcon-upload-endpoint
4949
LOG_DIR: logs
@@ -53,8 +53,8 @@ x-common-environment: &common-environment
5353
REDIS_PORT: 6379
5454
OPENAI_API_KEY_FILE: /run/secrets/openai-api-key
5555
# AWS Configuration read from GitHub Actions secrets
56-
AWS_ACCESS_KEY_ID_FILE: /run/secrets/aws-access-key
57-
AWS_SECRET_ACCESS_KEY_FILE: /run/secrets/aws-secret-key
56+
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
57+
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
5858

5959
x-common-deploy: &common-deploy
6060
restart_policy:
@@ -104,7 +104,9 @@ services:
104104
networks:
105105
- traefik-public
106106
- default
107-
environment: *common-environment
107+
environment:
108+
NODE_ENV: staging
109+
<<: *common-environment
108110
deploy:
109111
<<: *common-deploy
110112
labels:
@@ -162,13 +164,13 @@ services:
162164
reel-creator:
163165
image: ghcr.io/streamethorg/streameth-platform/reel-creator:staging
164166
environment:
165-
NODE_ENV: development
167+
NODE_ENV: staging
166168
SERVER_WEBHOOK_URL: https://staging.api.streameth.org/webhook/remotion
167169
SERVER_WEBHOOK_SECRET_FILE: /run/secrets/remotion-webhook-secret
168170
AWS_ACCESS_KEY_ID_FILE: /run/secrets/aws-access-key
169171
AWS_SECRET_ACCESS_KEY_FILE: /run/secrets/aws-secret-key
170172
BUCKET_NAME: streameth-develop
171-
BUCKET_URL: https://streameth-staging.ams3.digitaloceanspaces.com
173+
BUCKET_URL: https://streameth-develop.ams3.digitaloceanspaces.com
172174
SPACES_KEY_FILE: /run/secrets/spaces-key
173175
SPACES_SECRET_FILE: /run/secrets/spaces-secret
174176
SITE_NAME: rendering-engine
@@ -181,11 +183,11 @@ services:
181183
labels:
182184
- "traefik.enable=true"
183185
- "traefik.docker.network=traefik-public"
184-
- "traefik.http.routers.reel-creator-staging.rule=Host(`staging.remotion.streameth.org`)"
186+
- "traefik.http.routers.reel-creator-staging.rule=Host(`staging.api.streameth.org`)"
187+
- "traefik.http.services.reel-creator-staging.loadbalancer.server.port=3000"
185188
- "traefik.http.routers.reel-creator-staging.service=reel-creator-staging"
186189
- "traefik.http.routers.reel-creator-staging.tls=true"
187190
- "traefik.http.routers.reel-creator-staging.tls.certresolver=myresolver"
188-
- "traefik.http.services.reel-creator-staging.loadbalancer.server.port=3000"
189191
secrets:
190192
- aws-access-key
191193
- aws-secret-key
@@ -198,7 +200,6 @@ services:
198200
volumes:
199201
- mongodb_data:/data/db
200202
environment:
201-
NODE_ENV: development
202203
MONGO_INITDB_DATABASE: streameth-staging
203204
MONGO_INITDB_ROOT_USERNAME: root
204205
MONGO_INITDB_ROOT_PASSWORD_FILE: /run/secrets/db-password
@@ -244,7 +245,6 @@ services:
244245
- redis
245246
environment:
246247
<<: *common-environment
247-
REMOTION_WEBHOOK_URL: https://staging.api.streameth.org/remotion-webhook
248248
deploy:
249249
<<: *common-deploy
250250
mode: replicated

packages/reel-creator/app/api/lambda/progress/route.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,9 @@ import {
1313
TIMEOUT,
1414
WEBHOOK_SECRET,
1515
WEBHOOK_URL,
16+
AWS_ACCESS_KEY_ID,
17+
AWS_SECRET_ACCESS_KEY,
1618
} from "../../../../config.mjs";
17-
import * as fs from 'fs';
18-
19-
// Read AWS credentials from secret files
20-
const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID_FILE ?
21-
fs.readFileSync(process.env.AWS_ACCESS_KEY_ID_FILE, 'utf8').trim() :
22-
process.env.AWS_ACCESS_KEY_ID;
23-
24-
const AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY_FILE ?
25-
fs.readFileSync(process.env.AWS_SECRET_ACCESS_KEY_FILE, 'utf8').trim() :
26-
process.env.AWS_SECRET_ACCESS_KEY;
2719

2820
export const POST = executeApi<ProgressResponse, typeof ProgressRequest>(
2921
ProgressRequest,
@@ -35,8 +27,15 @@ export const POST = executeApi<ProgressResponse, typeof ProgressRequest>(
3527
!WEBHOOK_SECRET ||
3628
!SITE_NAME
3729
) {
30+
console.error('Missing required environment variables:', {
31+
hasAwsKeyId: !!AWS_ACCESS_KEY_ID,
32+
hasAwsSecretKey: !!AWS_SECRET_ACCESS_KEY,
33+
hasWebhookUrl: !!WEBHOOK_URL,
34+
hasWebhookSecret: !!WEBHOOK_SECRET,
35+
hasSiteName: !!SITE_NAME
36+
});
3837
throw new TypeError(
39-
"Set up Remotion Lambda to render videos. See the README.md for how to do so."
38+
"Missing required environment variables for Remotion Lambda. Check the logs for details."
4039
);
4140
}
4241

packages/reel-creator/app/api/lambda/render/route.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ import { RenderRequest } from "../../../../types/schema";
2323
export const POST = executeApi<RenderMediaOnLambdaOutput, typeof RenderRequest>(
2424
RenderRequest,
2525
async (req, body) => {
26-
// console.log('Debug environment variables:');
27-
// console.log('AWS_ACCESS_KEY_ID:', AWS_ACCESS_KEY_ID ? 'defined' : 'undefined');
28-
// console.log('AWS_SECRET_ACCESS_KEY:', AWS_SECRET_ACCESS_KEY ? 'defined' : 'undefined');
29-
// console.log('WEBHOOK_URL:', WEBHOOK_URL);
30-
// console.log('WEBHOOK_SECRET:', WEBHOOK_SECRET ? 'defined' : 'undefined');
31-
// console.log('SITE_NAME:', SITE_NAME);
32-
3326
if (
3427
!AWS_ACCESS_KEY_ID ||
3528
!AWS_SECRET_ACCESS_KEY ||

packages/reel-creator/config.mjs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
11
import { VERSION } from "remotion/version";
2-
3-
console.log('Raw environment variables in config.mjs:');
4-
console.log('SERVER_WEBHOOK_URL:', process.env.SERVER_WEBHOOK_URL);
5-
console.log('SERVER_WEBHOOK_SECRET_FILE:', process.env.SERVER_WEBHOOK_SECRET_FILE);
6-
console.log('AWS_ACCESS_KEY_ID:', process.env.AWS_ACCESS_KEY_ID);
7-
console.log('AWS_SECRET_ACCESS_KEY:', process.env.AWS_SECRET_ACCESS_KEY);
2+
import * as fs from 'fs';
83

94
/**
105
* Use autocomplete to get a list of available regions.
116
* @type {import('@remotion/lambda').AwsRegion}
127
*/
138

9+
1410
const readSecretFile = (path) => {
15-
if (process.env.NODE_ENV === 'development') {
16-
return path;
17-
}
18-
try {
19-
return fs.readFileSync(path, 'utf8').trim();
20-
} catch (error) {
21-
console.error(`Error reading secret file ${path}:`, error);
22-
throw error;
23-
}
24-
};
11+
// Add debug logging
12+
console.log('Attempting to read secret file, path:', path);
13+
14+
if (!path) {
15+
console.warn('No path provided for secret file');
16+
return undefined;
17+
}
18+
19+
if (process.env.NODE_ENV === 'development') {
20+
return path;
21+
}
22+
23+
try {
24+
return fs.readFileSync(path, 'utf8').trim();
25+
} catch (error) {
26+
console.error(`Error reading secret file ${path}:`, error);
27+
return undefined;
28+
}
29+
};
2530

2631
export const REGION = "us-east-2";
2732

@@ -31,7 +36,6 @@ export const DISK = 10240;
3136
export const TIMEOUT = 900;
3237

3338
export const WEBHOOK_URL = process.env.SERVER_WEBHOOK_URL;
34-
export const WEBHOOK_SECRET = readSecretFile(process.env.SERVER_WEBHOOK_SECRET_FILE);
35-
export const AWS_ACCESS_KEY_ID = readSecretFile(process.env.AWS_ACCESS_KEY_ID_FILE);
36-
export const AWS_SECRET_ACCESS_KEY = readSecretFile(process.env.AWS_SECRET_ACCESS_KEY_FILE);
37-
39+
export const WEBHOOK_SECRET = process.env.SERVER_WEBHOOK_SECRET_FILE;
40+
export const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;
41+
export const AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY;

packages/server/src/app.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ import { RegisterRoutes } from './routes/routes';
1515
import * as swaggerDocument from './swagger/swagger.json';
1616
import { logger } from './utils/logger';
1717
import ErrorMiddleware from './middlewares/error.middleware';
18+
1819
class App {
1920
public app: express.Application;
2021
private env: string;
2122
private port: string | number;
2223

2324
constructor() {
2425
this.app = express();
25-
this.env = config.appEnv || 'development';
26+
this.env = config.appEnv;
2627
this.port = config.port || 3400;
2728

2829
this.connectToDatabase();
@@ -39,7 +40,7 @@ class App {
3940
listen() {
4041
this.app.listen(this.port, () => {
4142
logger.info(`=================================`);
42-
logger.info(`======= ENV: ${this.env} =======`);
43+
logger.info(`======= ENV: ${this.env} ========`);
4344
logger.info(`🚀 App listening on the port ${this.port}`);
4445
logger.info(`=================================`);
4546
});
@@ -57,7 +58,7 @@ class App {
5758
getServer() {
5859
return this.app;
5960
}
60-
61+
6162
private async connectToDatabase() {
6263
if (this.env !== 'production') {
6364
set('debug', true);

packages/server/src/config/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const config = {
8787
remotion: {
8888
id: validatedEnv.REMOTION_ID,
8989
host: validatedEnv.REMOTION_BASE_URL,
90-
webhookSecretKey: validatedEnv.REMOTION_WEBHOOK_SECRET_FILE,
90+
webhookSecretKey: readSecretFile(validatedEnv.REMOTION_WEBHOOK_SECRET_FILE),
9191
},
9292
redis: {
9393
host: validatedEnv.REDIS_HOST,

packages/server/src/databases/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { config } from '@config';
22
const { host, user, name, password } = config.db;
3+
4+
console.log('Database connection details:');
5+
console.log('Host:', host);
6+
console.log('User:', user);
7+
console.log('Database:', name);
8+
console.log('Password length:', password?.length);
9+
310
export const dbConnection = {
411
url: `mongodb://${user}:${password}@${host}/${name}?authSource=admin&retryWrites=true&w=majority`,
512
// For local development use this url

packages/server/src/services/clipEditor.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ export class ClipEditorService extends SessionService {
131131

132132
const data = await response.json();
133133

134-
135134
await ClipEditor.findByIdAndUpdate(
136135
clipEditor._id,
137136
{

0 commit comments

Comments
 (0)