-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.local
63 lines (44 loc) · 1.76 KB
/
Dockerfile.local
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
# alpine version should match the version in .nvmrc as closely as possible
FROM node:14.18.2-alpine3.12@sha256:60ebf5d469a72fe510cb197c4a251a92de87f01361d2d8589268b1c641a061ac
ARG VERSION
# Install git
RUN apk add --update git
# Install python make and g++. They are needed when building node-sass.
RUN apk add python2 make g++
# Install tooling
RUN apk add openssl curl ca-certificates
# Install nginx repo
RUN printf "%s%s%s\n" "http://nginx.org/packages/alpine/v" `egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release` "/main" | tee -a /etc/apk/repositories
# Install nginx key
RUN curl -o /tmp/nginx_signing.rsa.pub https://nginx.org/keys/nginx_signing.rsa.pub
# Check key
RUN openssl rsa -pubin -in /tmp/nginx_signing.rsa.pub -text -noout
# Move key to storage
RUN mv /tmp/nginx_signing.rsa.pub /etc/apk/keys/
# Install nginx
RUN apk add --update nginx && \
rm -rf /var/cache/apk/*
RUN mkdir -p /run/nginx
# Stream the nginx logs to stdout and stderr
RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log
# Add nginx config
COPY nginx-docker-local.conf /etc/nginx/nginx.conf
# Use changes to package.json to force Docker not to use the cache
# when we change our application's dependencies:
COPY package.json /tmp/package.json
COPY yarn.lock /tmp/yarn.lock
WORKDIR /tmp
RUN ["yarn", "install"]
# Add the project files (works with .dockerignore to exclude node_modules, dist)
COPY . /app
# Copy possibly cached node_modules to app dir
RUN ["cp", "-a", "/tmp/node_modules", "/app/"]
# Build the dist dir containing the static files
WORKDIR /app
# Create version.txt
RUN echo "$VERSION" > src/version.txt
RUN ["npm", "run", "build", "--", "--prod", "--output-hashing=all"]
# Start web server and expose http
EXPOSE 80
CMD ["nginx"]