forked from samisalkosuo/ffmpeg-api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
69 lines (52 loc) · 1.5 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#####################################################################
#
# A Docker image to convert audio and video for web using web API
#
# with
# - FFMPEG (built)
# - NodeJS
# - fluent-ffmpeg
#
# For more on Fluent-FFMPEG, see
#
# https://github.com/fluent-ffmpeg/node-fluent-ffmpeg
#
# Original image and FFMPEG API by Paul Visco
# https://github.com/surebert/docker-ffmpeg-service
#
#####################################################################
# Stage 1: Build
FROM node:16-alpine as build
RUN apk add --no-cache git
# Install pkg globally
RUN npm install -g pkg
# Define cache path for pkg
ENV PKG_CACHE_PATH /usr/cache
# Set working directory
WORKDIR /usr/src/app
# Copy package.json and package-lock.json for dependency installation
COPY ./src/package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application source code
COPY ./src .
# Create a single binary file
RUN pkg --targets node16-alpine-x64 /usr/src/app
# Stage 2: Production
FROM jrottenberg/ffmpeg:4.2-alpine311
# Create a non-root user
RUN adduser --disabled-password --home /home/ffmpgapi ffmpgapi
# Set working directory
WORKDIR /home/ffmpgapi
# Copy files from build stage
COPY --from=build /usr/src/app/ffmpegapi .
COPY --from=build /usr/src/app/index.md .
# Set proper permissions
RUN chown ffmpgapi:ffmpgapi * && chmod 755 ffmpegapi
# Expose port 3000
EXPOSE 3000
# Change to non-root user
USER ffmpgapi
# Define entrypoint and default command
ENTRYPOINT []
CMD ["./ffmpegapi"]