don't gzip static files, and always commit them

This commit is contained in:
Adam Piontek 2022-08-14 15:09:30 -04:00
parent 64e310b598
commit 10f284da6f
68 changed files with 406 additions and 74 deletions

2
.gitignore vendored
View file

@ -35,7 +35,7 @@ npm-debug.log
# Since we are building assets from assets/,
# we ignore priv/static. You may want to comment
# this depending on your deployment strategy.
/priv/static/
#/priv/static/
# Files matching config/*.secret.exs pattern contain sensitive
# data and you should not commit them into version control.

132
README.md
View file

@ -7,84 +7,72 @@ Written in Elixir & Phoenix LiveView, with Bootstrap v5.
## TODO
- [X] ~~*Proper modal to delete shifts?*~~ [2022-08-14]
- [ ] move runtime config out of compile-time config files, to move towards supporting releases
- [ ] probably need to use `def get_app_config` style functions instead of `@module_var` module variables, ([see this](https://stephenbussey.com/2019/01/03/understanding-compile-time-dependencies-in-elixir-a-bug-hunt.html))
- [ ] Update tests, which are probably all way out of date. But I also don't care that much for this project...
## Deploying
The below notes are old; I'm using a docker build to deploy this now. Will document when I have time.
I'm using a dumb & simple docker approach to deploying this now. Nothing automated, the basic steps are:
### New versions
1. ensure latest assets are built, digested, and committed to the repo
When improvements are made, we can update the deployed version like so:
```shell
# rebuild static assets:
rm -rf ./priv/static/*
npm --prefix assets run build
MIX_ENV=prod mix phx.digest
# then do a new commit and push...
```
2. on server, build a new container, and run it
### Simple dockerfile
```dockerfile
# ./Dockerfile
# Extend from the official Elixir image
FROM elixir:1.13.4-otp-25-alpine
# # install the package postgresql-client to run pg_isready within entrypoint script
# RUN apt-get update && \
# apt-get install -y postgresql-client
# Copy the entrypoint script
COPY ./entrypoint.sh /entrypoint.sh
# Create app directory and copy the Elixir projects into it
RUN mkdir /app
COPY ./app /app
WORKDIR /app
# Install the build tools we'll need
RUN apk update && \
apk upgrade --no-cache && \
apk add --no-cache \
build-base && \
mix local.rebar --force && \
mix local.hex --force
# The environment to build with
ENV MIX_ENV=prod
# Get deps and compile
RUN mix do deps.get, deps.compile, compile
# Start command
CMD = ["/entrypoint.sh"]
```
### Simple entrypoint script
```shell
cd ${SHIFT73K_BASE_DIR}
# update from master
/usr/bin/git pull 73k master
# fetch prod deps & compile
/usr/bin/mix deps.get --only prod
MIX_ENV=prod /usr/bin/mix compile
# perform any migrations
MIX_ENV=prod /usr/bin/mix ecto.migrate
# update node packages via package-lock.json
/usr/bin/npm --prefix ./assets/ ci
# rebuild static assets:
rm -rf ./priv/static/*
/usr/bin/npm --prefix ./assets/ run build
MIX_ENV=prod /usr/bin/mix phx.digest
# rebuild release
MIX_ENV=prod /usr/bin/mix release --overwrite
# restart service
sudo /bin/systemctl restart shift73k.service
#!/bin/ash
export MIX_ENV="prod"
cd /app
exec mix ecto.migrate && mix phx.server
```
### systemd unit:
```ini
[Unit]
Description=Shift73k service
After=local-fs.target network.target
[Service]
Type=simple
User=runuser
Group=runuser
WorkingDirectory=/opt/shift73k/_build/prod/rel/shift73k
ExecStart=/opt/shift73k/_build/prod/rel/shift73k/bin/shift73k start
ExecStop=/opt/shift73k/_build/prod/rel/shift73k/bin/shift73k stop
#EnvironmentFile=/etc/default/myApp.env
Environment=LANG=en_US.utf8
Environment=MIX_ENV=prod
#Environment=PORT=4000
LimitNOFILE=65535
UMask=0027
SyslogIdentifier=shift73k
Restart=always
[Install]
WantedBy=multi-user.target
```
### nginx config:
```conf
upstream phoenix {
server 127.0.0.1:4000 max_fails=5 fail_timeout=60s;
}
server {
location / {
allow all;
# Proxy Headers
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Cluster-Client-Ip $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
# WebSockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://phoenix;
}
}
```

View file

@ -25,7 +25,7 @@ defmodule Shift73kWeb.Endpoint do
plug Plug.Static,
at: "/",
from: :shift73k,
gzip: (Mix.env() not in [:dev, :test]),
gzip: false,
only: ~w(assets
android-chrome-192x192.png
android-chrome-512x512.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

82
priv/static/assets/app.js Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<TileColor>#ee6c4d</TileColor>
</tile>
</msapplication>
</browserconfig>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<TileColor>#ee6c4d</TileColor>
</tile>
</msapplication>
</browserconfig>

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 850 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 850 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
priv/static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -0,0 +1,5 @@
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-agent: *
# Disallow: /

5
priv/static/robots.txt Normal file
View file

@ -0,0 +1,5 @@
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-agent: *
# Disallow: /

BIN
priv/static/robots.txt.gz Normal file

Binary file not shown.

View file

@ -0,0 +1,48 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="700.000000pt" height="700.000000pt" viewBox="0 0 700.000000 700.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.11, written by Peter Selinger 2001-2013
</metadata>
<g transform="translate(0.000000,700.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M1442 6981 c-49 -23 -86 -61 -109 -111 -15 -32 -21 -104 -23 -271 l0
-36 -242 0 c-134 0 -265 -3 -293 -7 -27 -4 -66 -10 -84 -13 -134 -20 -324
-125 -440 -242 -102 -105 -205 -285 -224 -397 -3 -16 -10 -51 -16 -79 -7 -34
-10 -871 -10 -2555 l0 -2505 24 -91 c44 -173 125 -314 246 -430 61 -57 180
-144 199 -144 5 0 24 -9 42 -19 18 -11 74 -32 123 -48 l90 -28 2770 0 2770 0
79 23 c240 69 415 204 543 417 27 46 56 115 81 195 l27 85 2 2530 c1 2396 1
2534 -16 2610 -25 109 -44 161 -93 247 -134 238 -356 394 -623 438 -39 7 -181
12 -318 13 -136 0 -250 4 -253 8 -3 5 -5 59 -6 121 -1 134 -16 192 -60 236
-44 46 -81 63 -147 68 -80 6 -153 -31 -196 -101 -29 -47 -30 -53 -33 -190 l-4
-142 -1749 0 -1749 0 0 127 c0 136 -9 176 -49 227 -58 73 -176 102 -259 64z
m4820 -880 c143 -46 254 -168 289 -317 13 -56 18 -4891 5 -4979 -12 -83 -68
-186 -132 -244 -63 -57 -111 -85 -188 -108 -45 -13 -366 -15 -2722 -15 -1469
0 -2691 3 -2715 7 -72 12 -165 60 -224 116 -64 60 -119 163 -131 244 -4 28 -7
1153 -7 2500 l0 2450 22 63 c12 35 33 82 47 104 61 95 181 177 289 195 28 5
1254 8 2725 7 l2675 -1 67 -22z"/>
<path d="M1255 5463 c-50 -13 -110 -64 -138 -118 -19 -37 -21 -57 -22 -300 -2
-293 2 -321 64 -385 68 -72 -109 -67 2361 -66 l2225 1 40 22 c54 29 82 61 104
119 16 43 18 80 17 314 l-2 265 -26 42 c-34 51 -81 88 -133 102 -28 8 -681 11
-2255 10 -1218 -1 -2224 -4 -2235 -6z"/>
<path d="M3657 3928 c-52 -14 -131 -87 -145 -136 -8 -26 -12 -128 -12 -298 0
-235 2 -263 20 -299 26 -55 50 -80 101 -107 42 -22 55 -23 284 -25 132 -1 259
1 283 4 63 8 131 58 161 117 25 49 25 52 26 309 0 171 -4 272 -11 294 -18 50
-60 101 -107 125 -40 22 -54 23 -302 25 -152 1 -276 -3 -298 -9z"/>
<path d="M4950 3921 c-59 -24 -115 -88 -129 -149 -7 -29 -10 -143 -9 -302 3
-242 4 -257 25 -290 33 -53 73 -86 123 -103 36 -12 95 -14 295 -13 137 2 266
6 285 11 50 12 124 89 138 145 17 70 14 525 -5 575 -19 50 -88 117 -136 132
-23 7 -134 11 -289 11 -221 1 -259 -2 -298 -17z"/>
<path d="M1465 2612 c-66 -19 -130 -85 -143 -146 -5 -26 -9 -160 -8 -299 1
-275 4 -292 64 -353 59 -59 82 -63 371 -64 264 -1 265 0 315 25 57 28 98 79
115 141 11 41 14 457 4 528 -9 60 -60 127 -118 156 -49 24 -55 25 -302 25
-184 1 -265 -3 -298 -13z"/>
<path d="M2777 2613 c-60 -17 -122 -79 -139 -138 -10 -33 -13 -115 -13 -303 1
-242 3 -259 23 -298 24 -48 69 -88 119 -109 44 -19 514 -22 577 -4 54 15 93
46 124 99 l27 45 0 285 0 285 -25 40 c-28 46 -40 58 -95 87 -38 20 -54 22
-297 23 -183 1 -270 -3 -301 -12z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -0,0 +1,48 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="700.000000pt" height="700.000000pt" viewBox="0 0 700.000000 700.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.11, written by Peter Selinger 2001-2013
</metadata>
<g transform="translate(0.000000,700.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M1442 6981 c-49 -23 -86 -61 -109 -111 -15 -32 -21 -104 -23 -271 l0
-36 -242 0 c-134 0 -265 -3 -293 -7 -27 -4 -66 -10 -84 -13 -134 -20 -324
-125 -440 -242 -102 -105 -205 -285 -224 -397 -3 -16 -10 -51 -16 -79 -7 -34
-10 -871 -10 -2555 l0 -2505 24 -91 c44 -173 125 -314 246 -430 61 -57 180
-144 199 -144 5 0 24 -9 42 -19 18 -11 74 -32 123 -48 l90 -28 2770 0 2770 0
79 23 c240 69 415 204 543 417 27 46 56 115 81 195 l27 85 2 2530 c1 2396 1
2534 -16 2610 -25 109 -44 161 -93 247 -134 238 -356 394 -623 438 -39 7 -181
12 -318 13 -136 0 -250 4 -253 8 -3 5 -5 59 -6 121 -1 134 -16 192 -60 236
-44 46 -81 63 -147 68 -80 6 -153 -31 -196 -101 -29 -47 -30 -53 -33 -190 l-4
-142 -1749 0 -1749 0 0 127 c0 136 -9 176 -49 227 -58 73 -176 102 -259 64z
m4820 -880 c143 -46 254 -168 289 -317 13 -56 18 -4891 5 -4979 -12 -83 -68
-186 -132 -244 -63 -57 -111 -85 -188 -108 -45 -13 -366 -15 -2722 -15 -1469
0 -2691 3 -2715 7 -72 12 -165 60 -224 116 -64 60 -119 163 -131 244 -4 28 -7
1153 -7 2500 l0 2450 22 63 c12 35 33 82 47 104 61 95 181 177 289 195 28 5
1254 8 2725 7 l2675 -1 67 -22z"/>
<path d="M1255 5463 c-50 -13 -110 -64 -138 -118 -19 -37 -21 -57 -22 -300 -2
-293 2 -321 64 -385 68 -72 -109 -67 2361 -66 l2225 1 40 22 c54 29 82 61 104
119 16 43 18 80 17 314 l-2 265 -26 42 c-34 51 -81 88 -133 102 -28 8 -681 11
-2255 10 -1218 -1 -2224 -4 -2235 -6z"/>
<path d="M3657 3928 c-52 -14 -131 -87 -145 -136 -8 -26 -12 -128 -12 -298 0
-235 2 -263 20 -299 26 -55 50 -80 101 -107 42 -22 55 -23 284 -25 132 -1 259
1 283 4 63 8 131 58 161 117 25 49 25 52 26 309 0 171 -4 272 -11 294 -18 50
-60 101 -107 125 -40 22 -54 23 -302 25 -152 1 -276 -3 -298 -9z"/>
<path d="M4950 3921 c-59 -24 -115 -88 -129 -149 -7 -29 -10 -143 -9 -302 3
-242 4 -257 25 -290 33 -53 73 -86 123 -103 36 -12 95 -14 295 -13 137 2 266
6 285 11 50 12 124 89 138 145 17 70 14 525 -5 575 -19 50 -88 117 -136 132
-23 7 -134 11 -289 11 -221 1 -259 -2 -298 -17z"/>
<path d="M1465 2612 c-66 -19 -130 -85 -143 -146 -5 -26 -9 -160 -8 -299 1
-275 4 -292 64 -353 59 -59 82 -63 371 -64 264 -1 265 0 315 25 57 28 98 79
115 141 11 41 14 457 4 528 -9 60 -60 127 -118 156 -49 24 -55 25 -302 25
-184 1 -265 -3 -298 -13z"/>
<path d="M2777 2613 c-60 -17 -122 -79 -139 -138 -10 -33 -13 -115 -13 -303 1
-242 3 -259 23 -298 24 -48 69 -88 119 -109 44 -19 514 -22 577 -4 54 15 93
46 124 99 l27 45 0 285 0 285 -25 40 c-28 46 -40 58 -95 87 -38 20 -54 22
-297 23 -183 1 -270 -3 -301 -12z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

View file

@ -0,0 +1,18 @@
{
"name": "Shift73k",
"short_name": "Shift73k",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ee6c4d",
"background_color": "#ee6c4d"
}

View file

@ -0,0 +1,18 @@
{
"name": "Shift73k",
"short_name": "Shift73k",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ee6c4d",
"background_color": "#ee6c4d"
}