-
Notifications
You must be signed in to change notification settings - Fork 140
/
Dockerfile
35 lines (32 loc) · 1.38 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
FROM node:18-alpine AS build
WORKDIR /app
COPY . /app
RUN set -ex \
# Build JS-Application
&& npm install --production \
# Generate SSL-certificate (for HTTPS)
&& apk --no-cache add openssl \
&& openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout privkey.pem -out fullchain.pem \
-subj "/C=GB/ST=London/L=London/O=Mendhak/CN=my.example.com" \
-addext "subjectAltName=DNS:my.example.com,DNS:my.example.net,IP:192.168.50.108,IP:127.0.0.1" \
&& apk del openssl \
&& rm -rf /var/cache/apk/* \
# Delete unnecessary files
&& rm package* \
# Correct User's file access
&& chown -R node:node /app \
&& chmod +r /app/privkey.pem
FROM node:18-alpine AS final
LABEL \
org.opencontainers.image.title="http-https-echo" \
org.opencontainers.image.description="Docker image that echoes request data as JSON; listens on HTTP/S, with various extra features, useful for debugging." \
org.opencontainers.image.url="https://github.com/mendhak/docker-http-https-echo" \
org.opencontainers.image.documentation="https://github.com/mendhak/docker-http-https-echo/blob/master/README.md" \
org.opencontainers.image.source="https://github.com/mendhak/docker-http-https-echo" \
org.opencontainers.image.licenses="MIT"
WORKDIR /app
COPY --from=build /app /app
ENV HTTP_PORT=8080 HTTPS_PORT=8443
EXPOSE $HTTP_PORT $HTTPS_PORT
USER 1000
CMD ["node", "./index.js"]