diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0c7adb0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM nginx:1.20.1-alpine + + +# Add build-dir contents to image +COPY static/ /usr/share/nginx/html +COPY nginx.conf /etc/nginx/nginx.conf +COPY jurassicsystems.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..51f566b --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +# use the last git tag as the version. if not on current tag, it will be tag-last-commit-hash +GIT_TAG = $(shell git describe --tags --always 2>/dev/null) +VERSION ?= 4.1.22 #${GIT_TAG} +IMAGE_TAG ?= ${VERSION} + +# The Docker registry where images are pushed. +# Note that if you use an org (like on Quay and DockerHub), you should +# include that: quay.io/foo +REGISTRY = docker.io/lukepatrick + + +DOCKER_BUILD_FLAGS := + +DOCKER_NAME := jurassicsystems +DOCKER_RUN_FLAGS := --rm --restart always --name $(DOCKER_NAME) +DOCKER_RUN_PORT := 80 + +DOCKER_IMAGE = jurassicsystems + +AUDIT_BASE ?= '' + +.PHONY: help +help: ## This help. + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) + +.DEFAULT_GOAL := help + +.PHONY: docker-build +docker-build: ## Build the container + docker build -f Dockerfile $(DOCKER_BUILD_FLAGS) -t $(REGISTRY)/$(DOCKER_IMAGE):$(IMAGE_TAG) . + +# You must be logged into DOCKER_REGISTRY before you can push. +.PHONY: docker-push +docker-push: ## Publish the container to artifactory + docker push $(REGISTRY)/$(DOCKER_IMAGE):$(IMAGE_TAG) + + +.PHONY: docker-run +docker-run: vendor ## run the docker container +docker-run: $(addsuffix -run,$(IMAGES)) + +%-run: + docker run -p $(DOCKER_RUN_PORT):$(DOCKER_RUN_PORT)/tcp \ + $(DOCKER_RUN_FLAGS) \ + -d $(REGISTRY)/$*:$(IMAGE_TAG); + open http://localhost + +.PHONY: docker-exec +docker-exec: vendor ## exec into docker container + docker exec -it $(DOCKER_NAME) /bin/bash + diff --git a/README.md b/README.md index c9e1dbb..9003373 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,11 @@ HTML5/JavaScript recreation of the original Jurassic Park movie computer system. ## About Repo This project started out as a much smaller joke that got out of hand, so the implementation may not have lead to the most extensible of code bases. That being said, adding terminal commands, at least, should be fairly straight forward using the `addCommand` method in [jurassicSystems.js](https://github.com/tojrobinson/jurassicsystems.com/blob/master/static/js/jurassicSystems.js). +## Make - Docker +run `make` for helpful make commands for building a Docker container of this app. + + + ## License The MIT License (MIT) diff --git a/jurassicsystems.conf b/jurassicsystems.conf new file mode 100644 index 0000000..f1c9038 --- /dev/null +++ b/jurassicsystems.conf @@ -0,0 +1,37 @@ +# Expires map +map $sent_http_content_type $expires { + default off; + text/html epoch; + text/css max; + application/javascript max; + ~image/ max; +} + + +server { + listen 80; + access_log /var/log/nginx/access.log main; + error_log /var/log/nginx/error.log warn; + root /usr/share/nginx/html/; + index jurassicSystems.html; + + expires $expires; + error_page 404 /errorPage.html; + error_page 403 /errorPage.html; + + location ~* \.(css|js|jpg|png|gif|ico|ogg|mp3|wav|swf)$ { + expires max; + } + + location /system { + try_files /jurassicSystems.html =404; + } + + location /about { + try_files /about.html =404; + } + + location = /theking { + try_files /theKing.html =404; + } +} \ No newline at end of file diff --git a/nginx.conf b/nginx.conf index f714e2e..72dccaa 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,24 +1,55 @@ -server { - listen 80; - server_name jurassicsystems.com www.jurassicsystems.com; - root /home/treefingers/www/jurassicsystems.com/static; - index jurassicSystems.html; - error_page 404 /errorPage.html; - error_page 403 /errorPage.html; - - location ~* \.(css|js|jpg|png|gif|ico|ogg|mp3|wav|swf)$ { - expires max; - } - - location /system { - try_files /jurassicSystems.html =404; - } - - location /about { - try_files /about.html =404; - } - - location = /theking { - try_files /theKing.html =404; - } +# server { +# listen 80; +# server_name jurassicsystems.com www.jurassicsystems.com; +# root /home/treefingers/www/jurassicsystems.com/static; +# index jurassicSystems.html; +# error_page 404 /errorPage.html; +# error_page 403 /errorPage.html; + +# location ~* \.(css|js|jpg|png|gif|ico|ogg|mp3|wav|swf)$ { +# expires max; +# } + +# location /system { +# try_files /jurassicSystems.html =404; +# } + +# location /about { +# try_files /about.html =404; +# } + +# location = /theking { +# try_files /theKing.html =404; +# } +# } + +user nginx; +worker_processes auto; +error_log /var/log/nginx/error.log warn; +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + + log_format main '[$time_local] $remote_addr - $remote_user - $server_name to: $upstream_addr: $request upstream_response_time $upstream_response_time msec $msec request_time $request_time'; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + gzip on; + gzip_types text/plain text/javascript application/javascript; + gzip_min_length 1000; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + # Load modular configuration files from the /etc/nginx/conf.d directory. + # See http://nginx.org/en/docs/ngx_core_module.html#include + # for more information. + include /etc/nginx/conf.d/*.conf; }