generated from digicatapult/openapi-service-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
62 lines (49 loc) · 1.41 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
# syntax=docker/dockerfile:1.4
FROM node:16-alpine as builder
WORKDIR /morello-api
# Install base dependencies
RUN npm -g install [email protected]
COPY package*.json ./
COPY tsconfig.json ./
RUN npm ci
COPY . .
RUN npm run build
#Pull Assets
FROM node:16-alpine as assets
RUN apk --no-cache add curl
WORKDIR /tmp/
ARG TARGETPLATFORM
RUN <<EOF
#!/usr/bin/env sh
set -ex
if [ "$TARGETPLATFORM" = "linux/amd64" ]; then
export ARCHITECTURE=amd64;
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then
export ARCHITECTURE=arm64;
else
export ARCHITECTURE=amd64;
fi
curl -L https://github.com/gruntwork-io/fetch/releases/download/v0.4.5/fetch_linux_${ARCHITECTURE} --output ./fetch
chmod +x ./fetch
EOF
ARG MORELLO_EXAMPLES_VERSION=latest
ARG MORELLO_EXAMPLES_REPO=https://github.com/digicatapult/morello-examples
RUN <<EOF
#!/usr/bin/env sh
set -ex
./fetch --repo="${MORELLO_EXAMPLES_REPO}" --tag="${MORELLO_EXAMPLES_VERSION}" --release-asset="morello-examples.tar.gz" ./
mkdir /morello-examples
tar -xzf ./morello-examples.tar.gz -C /morello-examples
EOF
# Service
FROM node:16-alpine as service
RUN apk --no-cache add openssh
WORKDIR /morello-api
RUN npm -g install [email protected]
COPY package*.json ./
RUN npm ci --production
COPY --from=builder /morello-api/build .
COPY --from=builder /morello-api/config ./config
COPY --from=assets /morello-examples /morello-api/bin
EXPOSE 80
CMD [ "node", "./index.js" ]