Skip to content

Commit

Permalink
Merge pull request #381 from ICESat2-SlideRule/static-website-to-clou…
Browse files Browse the repository at this point in the history
…dfront-mc

Static website to cloudfront mc
  • Loading branch information
cugarteblair authored Mar 5, 2024
2 parents c78f984 + a1da475 commit bd59e5a
Show file tree
Hide file tree
Showing 22 changed files with 287 additions and 607 deletions.
16 changes: 15 additions & 1 deletion targets/slideruleearth-aws/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ PROXY_STAGE_DIR = $(STAGE)/proxy
TF_STAGE_DIR = $(STAGE)/tf
STATIC_WEB_SOURCE_DIR = $(ROOT)/docs
STATIC_WEB_STAGE_DIR = $(STAGE)/website
STATIC_WEB_EXPORT_DIR = $(STATIC_WEB_STAGE_DIR)/dist
INSTALL_DIR ?= $(SERVER_STAGE_DIR)

VERSION ?= latest
Expand All @@ -76,6 +77,7 @@ DOMAIN_ROOT = $(firstword $(subst ., ,$(DOMAIN)))
MYIP ?= $(shell (ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$$/\1/p'))
ENVVER = $(shell cd ../../ && git describe --abbrev --dirty --always --tags --long)
USERCFG ?=
DISTRIBUTION_ID = $(shell aws cloudfront list-distributions --query "DistributionList.Items[?Aliases.Items[0]=='$(DOMAIN)'].Id" --output text)

CLANG_VER ?= ""
CLANG_OPT = -DCMAKE_USER_MAKE_RULES_OVERRIDE=$(ROOT)/platforms/linux/ClangOverrides.txt -D_CMAKE_TOOLCHAIN_PREFIX=llvm-
Expand Down Expand Up @@ -204,10 +206,19 @@ static-website-docker: ## make the static website docker image; needs VERSION
static-website-run: ## locally run the static website; needs VERSION
docker run -it -p 8080:4000 --rm --name website $(ECR)/static-website:$(VERSION)

static-website-export: ## export static website to local host directory
-rm -Rf $(STATIC_WEB_EXPORT_DIR)
mkdir -p $(STATIC_WEB_EXPORT_DIR)
docker run -it --entrypoint /bin/bash -v ./docker/static-website:/host -v $(STATIC_WEB_EXPORT_DIR):/output --rm --name website $(ECR)/static-website:$(VERSION) /host/export_dist.sh

static-website-live-update: # Update the static web site docs in the S3 bucket and invalidate the CloudFront cache
aws s3 sync $(STATIC_WEB_EXPORT_DIR)/jekyll/_site s3://$(DOMAIN) --delete
aws cloudfront create-invalidation --distribution-id $(DISTRIBUTION_ID) --paths "/*"

static-website-deploy: ## deploy static-website using terraform; needs VERSION, DOMAIN
cd terraform/static-website && terraform init
cd terraform/static-website && terraform workspace select $(DOMAIN)-static-website || terraform workspace new $(DOMAIN)-static-website
cd terraform/static-website && terraform apply -var docker_image_url_static-website=$(ECR)/static-website:$(VERSION) -var domain=$(DOMAIN) -var domain_root=$(DOMAIN_ROOT)
cd terraform/static-website && terraform apply -var domain=$(DOMAIN) -var domain_root=$(DOMAIN_ROOT)

static-website-destroy: ## destroy static-website using terraform; needs DOMAIN
cd terraform/static-website && terraform init
Expand Down Expand Up @@ -373,3 +384,6 @@ help: ## That's me!
@printf "\033[37m%-30s\033[0m %s\n" "#-target-----------------------description------------------------------------------------"
@grep -E '^[a-zA-Z_-].+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo ENVVER:$(ENVVER)
@echo DOMAIN: $(DOMAIN)
@echo DOMAIN_ROOT: $(DOMAIN_ROOT)
@echo DISTRIBUTION_ID: $(DISTRIBUTION_ID)
28 changes: 11 additions & 17 deletions targets/slideruleearth-aws/docker/static-website/Dockerfile.x86_64
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,29 @@ RUN apt-get update && \
nginx \
&& rm -rf /var/lib/apt/lists/*

# Install RTD Dependencies
RUN pip3 install -U Sphinx docutils==0.16 sphinx_markdown_tables sphinx_panels sphinx_rtd_theme
RUN pip3 install recommonmark

# Install Jekyll
RUN gem install webrick
RUN gem install jekyll bundler

# Install SlideRule Python Client
COPY sliderule/clients/python /sliderule/clients/python
RUN cd /sliderule/clients/python && pip install .

# Copy Over Jekyll Source
# Build Jekyll Website
COPY jekyll /jekyll
RUN chmod -R 777 /jekyll

# Build Jekyll Website
RUN cd /jekyll && bundle install
RUN cd /jekyll && bundle exec jekyll build
RUN chmod -R 744 /jekyll

# Copy Over RTD Source
COPY rtd /rtd
RUN chmod -R 777 /rtd
# Install SlideRule Python Client
COPY sliderule/clients/python /sliderule/clients/python
RUN cd /sliderule/clients/python && pip install .

# Install RTD Dependencies
RUN pip3 install 'sphinx>=5.0' docutils sphinx_markdown_tables sphinx_panels sphinx_rtd_theme
RUN pip3 install recommonmark

# Build RTD Website
COPY rtd /rtd
RUN chmod -R 777 /rtd
RUN make -C /rtd html

# Set Permissions
RUN chmod -R 744 /jekyll
RUN chmod -R 744 /rtd

# Combine Outputs to Well Known Jekyll Directory
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cp -Rv /srv/* /output
chmod -R 777 /output

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 0 additions & 101 deletions targets/slideruleearth-aws/terraform/static-website/alb.tf

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ terraform {
profile = "default"
region = "us-west-2"
}
}
}
7 changes: 0 additions & 7 deletions targets/slideruleearth-aws/terraform/static-website/cert.tf

This file was deleted.

71 changes: 0 additions & 71 deletions targets/slideruleearth-aws/terraform/static-website/ecs.tf

This file was deleted.

Loading

0 comments on commit bd59e5a

Please sign in to comment.