Skip to content

Commit

Permalink
Add make targets for the v2 build that is packaged together with v1 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbcox authored Aug 18, 2020
1 parent 80f584c commit e59abe5
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 21 deletions.
24 changes: 19 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
# Build layer
FROM ruby:2.5.1-stretch
# Optionally build v2 layer
FROM node:14.8.0-buster-slim as buildv2
ARG APP_VERSION=1
WORKDIR /work

# Ensure the public dir exists for v1 builds
RUN mkdir -p public

RUN if [ "${APP_VERSION}" -eq "2" ]; then npm -g install gatsby-cli ; fi
COPY v2/package.json v2/package-lock.json ./
RUN if [ "${APP_VERSION}" -eq "2" ]; then npm install --frozen-lockfile --non-interactive ; fi
COPY v2 .
RUN if [ "${APP_VERSION}" -eq "2" ]; then npm run build ; fi

# Build v1 layer
FROM ruby:2.5.1-stretch as buildv1
ARG APP_ENV=prod

RUN mkdir -p /work
WORKDIR work
WORKDIR /work
RUN gem install bundler
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
Expand All @@ -15,4 +28,5 @@ RUN bundle exec jekyll build
# Hosting Layer
FROM nginx
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=0 /work/_site/ /usr/share/nginx/html/
COPY --from=buildv1 /work/_site/ /usr/share/nginx/html/
COPY --from=buildv2 /work/public/ /usr/share/nginx/htmlv2/
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# casual contributors.

APP_ENV = dev
APP_VERSION = 1
PORT ?= 8080
TAG = bitcoin-cash-org

Expand All @@ -21,7 +22,7 @@ dev: _config.yml

.PHONY: container
container:
docker build --build-arg APP_ENV=$(APP_ENV) -t $(TAG) .
docker build --build-arg APP_ENV=$(APP_ENV) --build-arg APP_VERSION=$(APP_VERSION) -t $(TAG) .

.PHONY: run
run: container
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ make serve

# or test the Docker container with:
make run

# or test the v2 build with:
make run APP_VERSION=2
```

Open a browser to `localhost:4000` or `localhost:8080` respectively.
Expand Down
7 changes: 6 additions & 1 deletion nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ server {

rewrite ^/letter-from-the-ceo.pdf$ https://falkvinge.net/wp-content/uploads/2017/11/letter-from-the-ceo.pdf permanent;

root /usr/share/nginx/html;
root /usr/share/nginx;
location / {
try_files /htmlv2/$uri /html/$uri /htmlv2/$uri/index.html /html/$uri/index.html =404;
}

location /robots.txt {
alias /usr/share/nginx/html/robots/robots.txt;
Expand All @@ -62,10 +65,12 @@ server {

location ~* \.(jpg|jpeg|png|gif|ico)$ {
expires 30d;
try_files /htmlv2/$uri /html/$uri =404;
}

location ~* \.(css|js)$ {
expires 1d;
try_files /htmlv2/$uri /html/$uri =404;
}

error_page 500 502 503 504 /50x.html;
Expand Down
13 changes: 0 additions & 13 deletions v2/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
],
"license": "0BSD",
"scripts": {
"build": "gatsby build --prefix-paths",
"build": "gatsby telemetry --disable && gatsby build --prefix-paths",
"develop": "gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,scss}\" .babelrc",
"start": "npm run develop",
Expand Down

0 comments on commit e59abe5

Please sign in to comment.