-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
90 lines (64 loc) · 2.04 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
## Base image with node and entrypoint scripts ##
## =========================================== ##
FROM node:12.18.3-alpine3.11 AS base
LABEL maintainer="Lucas Clay <lclay@shipchain.io>"
ENV LANG C.UTF-8
RUN apk add --no-cache bash
RUN mkdir /app
WORKDIR /app
COPY ./compose/scripts/*.sh /
RUN chmod +x /*.sh
ENTRYPOINT ["/entrypoint.sh"]
## Image with system dependencies for building ##
## =========================================== ##
FROM base AS build
RUN apk add --no-cache \
libc6-compat \
# git, python, make, g++ are for installing/building several npm modules
git \
python2 \
make \
g++
## Image with dev-dependencies ##
## =========================== ##
FROM build AS test
COPY package.json /app/
COPY yarn.lock /app/
COPY .yarnclean /app/
RUN yarn --frozen-lockfile && yarn cache clean
COPY . /app/
RUN yarn compile
## Image only used for production building ##
## ======================================= ##
FROM build AS prod
COPY package.json /app/
COPY yarn.lock /app/
COPY .yarnclean /app/
RUN yarn --prod --frozen-lockfile && yarn cache clean
COPY . /app/
RUN yarn compile
## Image to be deployed to ECS with additional utils and no build tools ##
## ==================================================================== ##
FROM base AS deploy
# Install openssh for ECS management container
RUN apk add --no-cache \
openssh-server-pam \
python3 \
jq \
openssl \
shadow \
nano
RUN mkdir /var/run/sshd /etc/cron.d && touch /etc/pam.d/sshd
RUN sed -i 's/^CREATE_MAIL_SPOOL=yes/CREATE_MAIL_SPOOL=no/' /etc/default/useradd
# Keymaker for SSH auth via IAM
RUN pip3 install \
keymaker==1.0.8 \
awscli==1.16.95 && \
rm -rf /root/.cache/*
# Configure public key SSH
RUN echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config
RUN echo "UsePAM yes" >> /etc/ssh/sshd_config
RUN echo "AllowAgentForwarding yes" >> /etc/ssh/sshd_config
RUN echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
# Copy production node_modules without having to install packages in build
COPY --from=prod /app /app