Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerize the app with nginx #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
51 changes: 51 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
37 changes: 37 additions & 0 deletions jurassicsystems.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
77 changes: 54 additions & 23 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}