-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathDockerfile.BUILDS_AND_CDN
41 lines (36 loc) · 1.22 KB
/
Dockerfile.BUILDS_AND_CDN
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
## Build layer
# When update node ---> remember to update all .sh files
FROM node:20.5.0 as build
WORKDIR /app
COPY package.json yarn.lock ./
ENV DISABLE_HUSKY=true
COPY prepare.js ./
# Download dependencies
RUN yarn
# Copy source files
COPY . .
# Run tests and verify other requirements
RUN yarn verify
# Build project
ARG environment
ENV REACT_APP_ROUTER=hash
ENV PUBLIC_URL="."
RUN yarn build:$environment
## Publish into new CDN using SFTP
## Using a third party image here, with specific digest (f7f7607...) to avoid unwanted changes
FROM ttionya/openssh-client@sha256:f7f7607d56f09a7c42e246e9c256ff51cf2f0802e3b2d88da6537bea516fe142
COPY --from=build /app/build /source
ARG env_version
ARG CDN_SFTP_PORT
ARG CDN_SFTP_USERNAME
ARG CDN_SFTP_HOSTNAME
ARG CDN_SFTP_BASE
ARG SSH_PRIVATE_KEY
ARG SSH_KNOWN_HOSTS
RUN mkdir /root/.ssh/ &&\
echo "${SSH_PRIVATE_KEY}" > /root/.ssh/id_rsa &&\
chmod 600 /root/.ssh/id_rsa &&\
echo "${SSH_KNOWN_HOSTS}" > /root/.ssh/known_hosts &&\
chmod 600 /root/.ssh/known_hosts
RUN scp -P "${CDN_SFTP_PORT}" -r /source "${CDN_SFTP_USERNAME}@${CDN_SFTP_HOSTNAME}:/${CDN_SFTP_BASE}/doppler-webapp/${env_version}"
RUN echo "Files published on http://cdn.fromdoppler.com/doppler-webapp/${env_version}"