forked from kanton-bern/oerebViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
54 lines (39 loc) · 1.27 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
# build the nuxt app
FROM node:16-alpine as build-app
# create destination directory
RUN mkdir -p /app
WORKDIR /app
# copy the app, note .dockerignore
COPY . .
RUN npm install
RUN npm run generate
# build the server
# https://lipanski.com/posts/smallest-docker-image-static-website
FROM alpine:3.13.2 AS build-server
ARG THTTPD_VERSION=2.29
# Install all dependencies required for compiling thttpd
RUN apk add gcc musl-dev make
# Download thttpd sources
RUN wget http://www.acme.com/software/thttpd/thttpd-${THTTPD_VERSION}.tar.gz \
&& tar xzf thttpd-${THTTPD_VERSION}.tar.gz \
&& mv /thttpd-${THTTPD_VERSION} /thttpd
# Compile thttpd to a static binary which we can copy around
RUN cd /thttpd \
&& ./configure \
&& make CCOPT='-O2 -s -static' thttpd
# Create a non-root user to own the files and run our server
RUN adduser -D static
# Switch to the scratch image
FROM scratch
EXPOSE 3000
# Copy over the user
COPY --from=build-server /etc/passwd /etc/passwd
# Copy the thttpd static binary
COPY --from=build-server /thttpd/thttpd /
# Use our non-root user
USER static
WORKDIR /home/static
# Copy the static website
COPY --from=build-app /app/dist .
# Run thttpd
CMD ["/thttpd", "-D", "-h", "0.0.0.0", "-p", "3000", "-d", "/home/static", "-u", "static", "-l", "-", "-M", "60"]