-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MISC Refactor docker files to support dev and production (#121)
* MISC Refactor docker files to support dev and production, run nginx for test/production. * point compose to docker dev and we don't need node on the final container * run yarn install before copying app assets to cache that layer * restore --no-cache as the yarn cache won't be used when the package layer is invalidated * Refactor start command for nginx. * Add Route53 A alias record, env variables as part of build * woot! SSL support.
- Loading branch information
Showing
15 changed files
with
205 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ node_modules | |
Dockerfile | ||
README.me | ||
npm-debug.log | ||
yarn-error.log | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
REACT_APP_AUTH0_DOMAIN=forgingadventures.auth0.com | ||
REACT_APP_AUTH0_CLIENT_ID=AQ9U63ZdGNMfttXnztEiV5n7C8ZLwQSg | ||
REACT_APP_AUTH0_REDIRECT_URI=http://localhost:3000/login/callback | ||
REACT_APP_AUTH0_RENEWAL_REDIRECT_URI=http://localhost:3001/silent | ||
REACT_APP_AUTH0_REDIRECT_URI=https://play.forgingadventures.com/login/callback | ||
REACT_APP_AUTH0_AUDIENCE=https://api.forgingadventures.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
REACT_APP_AUTH0_DOMAIN=forgingadventures-staging.auth0.com | ||
REACT_APP_AUTH0_CLIENT_ID=i7Srpetd9dL9Dx1ckMIhBLFnSxksaVcz | ||
REACT_APP_AUTH0_REDIRECT_URI=http://localhost:3000/login/callback | ||
REACT_APP_AUTH0_RENEWAL_REDIRECT_URI=http://localhost:3001/silent | ||
REACT_APP_AUTH0_REDIRECT_URI=http://playquest.forgingadventures.com/login/callback | ||
REACT_APP_AUTH0_AUDIENCE=https://api-test.forgingadventures.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,42 @@ | ||
FROM node:8.9.1-alpine | ||
# The build container | ||
FROM node:8.9.4-alpine as builder | ||
|
||
# for dev only - extend watchers limit for CRA file watchers and auto-reload | ||
COPY ./etc/sysctl.conf /etc/sysctl.conf | ||
# install node packages first as we don't want to invalidate this layer during src code changes | ||
# but onlt when package.json changes | ||
COPY package.json /usr/src/app/ | ||
COPY yarn.lock /usr/src/app/ | ||
WORKDIR /usr/src/app | ||
RUN yarn install --frozen-lockfile --no-cache | ||
|
||
# define paths | ||
WORKDIR /app | ||
ADD . /app | ||
# copy application artifacts | ||
COPY /config /usr/src/app/config | ||
COPY /public /usr/src/app/public | ||
COPY /scripts /usr/src/app/scripts | ||
COPY /src /usr/src/app/src | ||
|
||
EXPOSE 3000 | ||
RUN mkdir /usr/src/app/build | ||
|
||
# Set env variables before build | ||
ARG REACT_APP_AUTH0_DOMAIN | ||
ARG REACT_APP_AUTH0_CLIENT_ID | ||
ARG REACT_APP_AUTH0_AUDIENCE | ||
ARG REACT_APP_AUTH0_REDIRECT_URI | ||
ENV REACT_APP_AUTH0_DOMAIN=$REACT_APP_AUTH0_DOMAIN | ||
ENV REACT_APP_AUTH0_CLIENT_ID=$REACT_APP_AUTH0_CLIENT_ID | ||
ENV REACT_APP_AUTH0_AUDIENCE=$REACT_APP_AUTH0_AUDIENCE | ||
ENV REACT_APP_AUTH0_REDIRECT_URI=$REACT_APP_AUTH0_REDIRECT_URI | ||
|
||
# build using production env for optimized build | ||
ENV NODE_ENV production | ||
RUN yarn build | ||
|
||
# The deployed container | ||
FROM nginx:1.13-alpine | ||
|
||
CMD yarn && yarn start | ||
COPY ./etc/nginx.conf /etc/nginx/ | ||
|
||
WORKDIR /usr/src/app | ||
COPY --from=builder /usr/src/app/build . | ||
|
||
EXPOSE 3000 | ||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM node:8.9.4-alpine | ||
|
||
# for dev only - extend watchers limit for CRA file watchers and auto-reload | ||
COPY ./etc/sysctl.conf /etc/sysctl.conf | ||
|
||
# define paths | ||
WORKDIR /app | ||
COPY . /app | ||
|
||
EXPOSE 3000 | ||
|
||
CMD yarn && yarn start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# /etc/nginx/nginx.conf | ||
|
||
user nginx; | ||
|
||
# Set number of worker processes automatically based on number of CPU cores. | ||
worker_processes auto; | ||
|
||
# Enables the use of JIT for regular expressions to speed-up their processing. | ||
pcre_jit on; | ||
|
||
# Configures default error logger. | ||
error_log stderr error; | ||
|
||
# Includes files with directives to load dynamic modules. | ||
include /etc/nginx/modules/*.conf; | ||
|
||
|
||
events { | ||
# The maximum number of simultaneous connections that can be opened by | ||
# a worker process. | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
# Includes mapping of file name extensions to MIME types of responses | ||
# and defines the default type. | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
# Name servers used to resolve names of upstream servers into addresses. | ||
# It's also needed when using tcpsocket and udpsocket in Lua modules. | ||
#resolver 208.67.222.222 208.67.220.220; | ||
|
||
# Don't tell nginx version to clients. | ||
server_tokens off; | ||
|
||
# Specifies the maximum accepted body size of a client request, as | ||
# indicated by the request header Content-Length. If the stated content | ||
# length is greater than this size, then the client receives the HTTP | ||
# error code 413. Set to 0 to disable. | ||
client_max_body_size 1m; | ||
|
||
# Timeout for keep-alive connections. Server will close connections after | ||
# this time. | ||
keepalive_timeout 65; | ||
|
||
# Sendfile copies data between one FD and other from within the kernel, | ||
# which is more efficient than read() + write(). | ||
sendfile on; | ||
|
||
# Don't buffer data-sends (disable Nagle algorithm). | ||
# Good for sending frequent small bursts of data in real time. | ||
tcp_nodelay on; | ||
|
||
# Causes nginx to attempt to send its HTTP response head in one packet, | ||
# instead of using partial frames. | ||
#tcp_nopush on; | ||
|
||
|
||
# Path of the file with Diffie-Hellman parameters for EDH ciphers. | ||
#ssl_dhparam /etc/ssl/nginx/dh2048.pem; | ||
|
||
# Specifies that our cipher suits should be preferred over client ciphers. | ||
ssl_prefer_server_ciphers on; | ||
|
||
# Enables a shared SSL cache with size that can hold around 8000 sessions. | ||
ssl_session_cache shared:SSL:2m; | ||
|
||
|
||
# Enable gzipping of responses. | ||
gzip on; | ||
|
||
# Set the Vary HTTP header as defined in the RFC 2616. | ||
gzip_vary on; | ||
|
||
# Enable checking the existence of precompressed files. | ||
#gzip_static on; | ||
|
||
# Enables gzipping of responses for the specified MIME types in addition to “text/html”. | ||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; | ||
|
||
|
||
# Specifies the main log format. | ||
log_format main '$request_time - $remote_addr - $remote_user [$time_local] ' | ||
'"$request" $status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
access_log /dev/stdout main; | ||
|
||
|
||
# Includes virtual hosts configs. | ||
include /etc/nginx/conf.d/*.conf; | ||
|
||
server { | ||
listen 3000; | ||
root /usr/src/app; | ||
|
||
location / { | ||
try_files $uri /index.html; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters