File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed
src/components/file/media Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 1
1
# Base node stage that sets up common config for dev & prod
2
2
FROM public.ecr.aws/docker/library/node:18-slim as node
3
3
4
- # Add wget in for healthchecks
4
+ # Install these native packages
5
5
RUN apt-get update \
6
- && apt-get install -y --no-install-recommends ca-certificates wget curl \
6
+ && apt-get install -y --no-install-recommends \
7
+ ca-certificates wget curl \
8
+ # Install ffprobe from here, as the npm version is manually published and as of comment segfaults with urls
9
+ ffmpeg \
7
10
&& apt-get clean -q -y \
8
11
&& rm -rf /var/lib/apt/lists/*
9
12
Original file line number Diff line number Diff line change 1
- import { path as ffprobeBinary } from '@ffprobe-installer/ffprobe' ;
1
+ import npmFfprobe from '@ffprobe-installer/ffprobe' ;
2
2
import { forwardRef , Inject , Injectable } from '@nestjs/common' ;
3
- import { execa } from 'execa' ;
3
+ import { CachedByArg as Once } from '@seedcompany/common' ;
4
+ import { $ , execa } from 'execa' ;
4
5
import { FFProbeResult } from 'ffprobe' ;
5
6
import { imageSize } from 'image-size' ;
6
7
import { ISize as ImageSize } from 'image-size/dist/types/interface' ;
@@ -69,11 +70,12 @@ export class MediaDetector {
69
70
}
70
71
71
72
private async ffprobe ( url : string ) : Promise < Partial < FFProbeResult > > {
73
+ const binaryPath = await this . getFfprobeBinaryPath ( ) ;
72
74
try {
73
75
return await retry (
74
76
async ( ) => {
75
77
const probe = await execa (
76
- ffprobeBinary ,
78
+ binaryPath ,
77
79
[
78
80
'-v' ,
79
81
'error' ,
@@ -104,4 +106,14 @@ export class MediaDetector {
104
106
return { } ;
105
107
}
106
108
}
109
+
110
+ @Once ( )
111
+ private async getFfprobeBinaryPath ( ) {
112
+ try {
113
+ await retry ( async ( ) => await $ `which ffprobe` , { retries : 3 } ) ;
114
+ return 'ffprobe' ;
115
+ } catch {
116
+ return npmFfprobe . path ;
117
+ }
118
+ }
107
119
}
You can’t perform that action at this time.
0 commit comments