-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.local
59 lines (42 loc) · 1.65 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
# alpine version should match the version in .nvmrc as closely as possible
FROM node:16.13.1-alpine3.14@sha256:a9b9cb880fa429b0bea899cd3b1bc081ab7277cc97e6d2dcd84bd9753b2027e1
ARG VERSION
# Install git
RUN apk add --update git
# 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
# 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)
ADD . /app
# Copy possibly cached node_modules to app dir
RUN ["cp", "-a", "/tmp/node_modules", "/app/"]
# Add nginx config
ADD nginx-docker-local.conf /etc/nginx/nginx.conf
# 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"]