Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Building a new proxy image will include the legacy assets
This is meant to address a potential WTF moment if anyone was to build
thechangelog/proxy image on their host without having the legacy static
assets present. The goal is for the legacy assets to be seamlessly
pulled just-in-time, at the time of building the proxy image, without
any extra hoops or WTF moments.

This approach makes use of Docker multi-stage builds:
https://docs.docker.com/develop/develop-images/multistage-build/

The resulting legacy_assets image is available via
https://hub.docker.com/r/thechangelog/legacy_assets/

[finishes #162167357]
  • Loading branch information
gerhard committed Nov 23, 2018
1 parent 5e1148d commit e207d9c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Makefile
Expand Up @@ -94,6 +94,14 @@ contrib: $(COMPOSE) ## Contribute to changelog.com by running a local copy (c)
.PHONY: c
c: contrib

.PHONY: legacy-assets
legacy-assets: $(DOCKER)
@echo "$(YELLOW)This is a secret target that is only meant to be executed if legacy assets are present locally$(NORMAL)" && \
echo "$(YELLOW)If this runs with an incorrect $(BOLD)./nginx/www/wp-content$(NORMAL)$(YELLOW), the resulting Docker image will miss relevant files$(NORMAL)" && \
read -rp "Are you sure that you want to continue? (y|n) " -n 1 && ([[ $$REPLY =~ ^[Yy]$$ ]] || exit) && \
cd nginx && $(DOCKER) build --tag thechangelog/legacy_assets . --file Dockerfile.legacy_assets && \
$(DOCKER) push thechangelog/legacy_assets

.PHONY: proxy
proxy: $(DOCKER) ## Builds & publishes thechangelog/proxy image
@cd nginx && export BUILD_VERSION=$$(date -u +'%Y-%m-%d') ; \
Expand Down
3 changes: 2 additions & 1 deletion nginx/Dockerfile
@@ -1,5 +1,6 @@
FROM thechangelog/legacy_assets AS legacy_assets
FROM jwilder/nginx-proxy

COPY ./www/wp-content /var/www/wp-content
COPY ./vhost.d/default /etc/nginx/vhost.d/default
COPY ./conf.d/changelog.conf /etc/nginx/conf.d/changelog.conf
COPY --from=legacy_assets /var/www/wp-content /var/www/wp-content
2 changes: 2 additions & 0 deletions nginx/Dockerfile.legacy_assets
@@ -0,0 +1,2 @@
FROM scratch
COPY ./www/wp-content /var/www/wp-content

0 comments on commit e207d9c

Please sign in to comment.