Skip to content

Commit

Permalink
Add deployment config
Browse files Browse the repository at this point in the history
  • Loading branch information
n2o committed Jul 12, 2022
1 parent ddd2490 commit bf4a86d
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM clojure:openjdk-17-tools-deps-bullseye AS shadow-build

WORKDIR /code

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt update && \
apt install -y yarn && \
yarn global add sass

# Cache and install JavaScript dependencies
COPY package.json .
COPY yarn.lock .
COPY .yarnrc .
# COPY resources/public/node_modules/ resources/public/node_modules/
RUN yarn install

COPY deps.edn .
RUN clojure -P -M:frontend

COPY . .

RUN yarn build

# ------------------------------------------------------------------------------

FROM nginx:alpine
# Default value is robots.txt, only on other environments a custom var is needed
RUN apk add --no-cache tzdata

WORKDIR /usr/share/nginx/html
COPY --from=shadow-build /code/resources/public .
COPY nginx/schnaq.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
71 changes: 71 additions & 0 deletions deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
io.kompose.service: academy
name: academy
namespace: schnaq-academy
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: academy
strategy: { }
template:
metadata:
labels:
io.kompose.service: academy
spec:
imagePullSecrets:
- name: gitlab-cs
containers:
- image: gitlab.cs.uni-duesseldorf.de:5001/dialogo/projects/academy
name: academy
resources:
requests:
memory: "256Mi"
cpu: "0.5"
limits:
memory: "512Mi"
cpu: "1"
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: academy
namespace: schnaq-academy
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
protocol: TCP
selector:
io.kompose.service: academy
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: academy-ingress
namespace: schnaq-academy
annotations:
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
cert-manager.io/cluster-issuer: "letsencrypt-production"
spec:
tls:
- hosts:
- academy.schnaq.com
- academy.schnaq.de
secretName: schnaq-academy-com
rules:
- host: academy.schnaq.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: academy
port:
number: 80
91 changes: 91 additions & 0 deletions nginx/schnaq.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
log_format json_analytics escape=json '{'
'"msec": "$msec", ' # request unixtime in seconds with a milliseconds resolution
'"connection": "$connection", ' # connection serial number
'"connection_requests": "$connection_requests", ' # number of requests made in connection
'"pid": "$pid", ' # process pid
'"request_id": "$request_id", ' # the unique request id
'"request_length": "$request_length", ' # request length (including headers and body)
'"remote_addr": "$remote_addr", ' # client IP
'"remote_user": "$remote_user", ' # client HTTP username
'"remote_port": "$remote_port", ' # client port
'"time_local": "$time_local", '
'"time_iso8601": "$time_iso8601", ' # local time in the ISO 8601 standard format
'"request": "$request", ' # full path no arguments if the request
'"request_uri": "$request_uri", ' # full path and arguments if the request
'"args": "$args", ' # args
'"status": "$status", ' # response status code
'"body_bytes_sent": "$body_bytes_sent", ' # the number of body bytes exclude headers sent to a client
'"bytes_sent": "$bytes_sent", ' # the number of bytes sent to a client
'"http_referer": "$http_referer", ' # HTTP referer
'"http_user_agent": "$http_user_agent", ' # user agent
'"http_x_forwarded_for": "$http_x_forwarded_for", ' # http_x_forwarded_for
'"http_host": "$http_host", ' # the request Host: header
'"server_name": "$server_name", ' # the name of the vhost serving the request
'"request_time": "$request_time", ' # request processing time in seconds with msec resolution
'"upstream": "$upstream_addr", ' # upstream backend server for proxied requests
'"upstream_connect_time": "$upstream_connect_time", ' # upstream handshake time incl. TLS
'"upstream_header_time": "$upstream_header_time", ' # time spent receiving upstream headers
'"upstream_response_time": "$upstream_response_time", ' # time spend receiving upstream body
'"upstream_response_length": "$upstream_response_length", ' # upstream response length
'"upstream_cache_status": "$upstream_cache_status", ' # cache HIT/MISS where applicable
'"ssl_protocol": "$ssl_protocol", ' # TLS protocol
'"ssl_cipher": "$ssl_cipher", ' # TLS cipher
'"scheme": "$scheme", ' # http or https
'"request_method": "$request_method", ' # request method
'"server_protocol": "$server_protocol", ' # request protocol, like HTTP/1.1 or HTTP/2.0
'"pipe": "$pipe", ' # "p" if request was pipelined, "." otherwise
'"gzip_ratio": "$gzip_ratio", '
'"http_cf_ray": "$http_cf_ray"'
# '"geoip_country_code": "$geoip_country_code"'
'}';

server {
include /etc/nginx/mime.types;
listen 80;
listen [::]:80;
server_name localhost;

#charset koi8-r;
access_log /var/log/nginx/access.log json_analytics;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
error_page 404 = /index.html;
}

#error_page 404 /404.html;
location ~ ^/404/$ {
return 404;
}
error_page 404 /index.html;
location = /index.html {
root /usr/share/nginx/html;
}

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

gzip on;
gzip_disable "msie6";

gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
text/plain
text/css
text/js
text/xml
text/javascript
application/javascript
application/json
application/xml
application/rss+xml
image/svg+xml;
}

0 comments on commit bf4a86d

Please sign in to comment.