forked from jason-fox/lepus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
94 lines (80 loc) · 3.18 KB
/
Dockerfile
File metadata and controls
94 lines (80 loc) · 3.18 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
ARG NODE_VERSION=20
ARG DISTROLESS_NODE_VERSION=nodejs20-debian12
ARG DOWNLOAD=latest
ARG GITHUB_REPOSITORY=lepus
ARG GITHUB_ACCOUNT=jason-fox
########################################################################################
#
# This build stage retrieves the source code from GitHub. The default download is the
# latest tip of the master of the named repository on GitHub.
#
# To obtain the latest stable release run this Docker file with the parameters:
# --no-cache --build-arg DOWNLOAD=stable
#
# To obtain any specific version of a release run this Docker file with the parameters:
# --no-cache --build-arg DOWNLOAD=1.7.0
#
# For development purposes, to create a development image including a running Distro,
# run this Docker file with the parameter:
#
# --target=builder
#
########################################################################################
FROM node:${NODE_VERSION} AS builder
# hadolint ignore=DL3008
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
COPY . /opt/adapter
WORKDIR /opt/adapter
# hadolint ignore=DL3008
RUN \
# Ensure that Git is installed prior to running npm install
apt-get install -y --no-install-recommends git && \
echo "INFO: npm install --production..." && \
npm install --only=prod --no-package-lock --no-optional && \
# Remove Git and clean apt cache
apt-get clean && \
apt-get remove -y git && \
apt-get -y autoremove
USER node
ENV NODE_ENV=development
# Ports used by application
EXPOSE ${WEB_APP_PORT:-3000} ${DUMMY_DEVICES_PORT:-3001}
CMD ["node", "/opt/adapter/bin/www"]
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s \
CMD npm run healthcheck
########################################################################################
#
# This build stage creates an anonymous user to be used with the distroless build
# as defined below.
#
########################################################################################
FROM node:${NODE_VERSION} AS anon-user
RUN sed -i -r "/^(root|nobody)/!d" /etc/passwd /etc/shadow /etc/group \
&& sed -i -r 's#^(.*):[^:]*$#\1:/sbin/nologin#' /etc/passwd
#
# The following creates a distroless build for production.
#
FROM gcr.io/distroless/${DISTROLESS_NODE_VERSION}
ARG TARGET
ARG GITHUB_ACCOUNT
ARG GITHUB_REPOSITORY
ARG NODE_VERSION
ARG SOURCE_COMMIT
ENV GIT_COMMIT=$SOURCE_COMMIT
LABEL "maintainer"="FIWARE Foundation <fiware.eu@gmail.com>"
LABEL "org.opencontainers.image.authors"="https://www.fiware.org/contact-us/"
LABEL "org.opencontainers.image.vendor"="FIWARE Foundation"
LABEL "org.opencontainers.image.licenses"="MIT"
LABEL "org.opencontainers.image.title"="FIWARE Lepus"
LABEL "org.opencontainers.image.description"="An NGSI-LD wrapper for use with NGSI-v2 Context Brokers. It understands the NGSI-LD endpoints and inputs, converts them to NGSI-v2"
LABEL "org.opencontainers.image.source"=https://github.com/${GITHUB_ACCOUNT}/${GITHUB_REPOSITORY}
LABEL "org.nodejs.version"=${NODE_VERSION}
COPY --from=builder /opt/adapter /opt/adapter
WORKDIR /opt/adapter
USER nobody
ENV NODE_ENV=production
# Ports used by application
EXPOSE ${WEB_APP_PORT:-3000}
CMD ["./bin/www"]
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s \
CMD ["/nodejs/bin/node", "./bin/healthcheck"]