feat: Build nginx-enabled Docker images for easy deployment
Signed-off-by: Christoph Heiss <contact@christoph-heiss.at>
This commit is contained in:
parent
ecfcaf5015
commit
4983ccd903
1
.dockerignore
Normal file
1
.dockerignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/node_modules
|
|
@ -5,11 +5,8 @@ end_of_line = lf
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 4
|
indent_size = 2
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
[*.md]
|
[*.md]
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
[*.html]
|
|
||||||
indent_size = 2
|
|
||||||
|
|
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
package-lock.json merge=binary
|
36
.github/workflows/build.yml
vendored
Normal file
36
.github/workflows/build.yml
vendored
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
name: Lint and build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint-and-build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 17
|
||||||
|
- run: npm clean-install
|
||||||
|
- run: npm run lint:scss
|
||||||
|
- run: npm run build
|
||||||
|
|
||||||
|
docker-image:
|
||||||
|
needs: lint-and-build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: docker/setup-buildx-action@v2
|
||||||
|
- uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
tags: |
|
||||||
|
ghcr.io/${{ github.repository }}:latest
|
||||||
|
push: ${{ github.ref == 'refs/heads/main' }}
|
9
.stylelintrc.json
Normal file
9
.stylelintrc.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"extends": "stylelint-config-standard-scss",
|
||||||
|
"rules": {
|
||||||
|
"declaration-empty-line-before": "never",
|
||||||
|
"scss/dollar-variable-colon-space-before": null,
|
||||||
|
"selector-class-pattern": "[a-z][a-zA-Z0-9]+",
|
||||||
|
"string-quotes": "single"
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,8 +3,7 @@ WORKDIR /app
|
||||||
RUN apk add --no-cache libc6-compat
|
RUN apk add --no-cache libc6-compat
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
ENV NODE_ENV production
|
RUN npm clean-install && npm run build
|
||||||
RUN npm clean-install && npm run prod
|
|
||||||
|
|
||||||
FROM nginx:1.23-alpine AS runner
|
FROM nginx:1.23-alpine AS runner
|
||||||
|
|
||||||
|
@ -21,7 +20,7 @@ server {\
|
||||||
root /var/www/html;\
|
root /var/www/html;\
|
||||||
try_files /index.html =404;\
|
try_files /index.html =404;\
|
||||||
\
|
\
|
||||||
location ~ ^/(robots.txt)$ {\
|
location ~ ^/(favicon.ico|robots.txt)$ {\
|
||||||
access_log off;\
|
access_log off;\
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
|
|
12
deploy.sh
12
deploy.sh
|
@ -1,12 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
npm run prod
|
|
||||||
|
|
||||||
rsync \
|
|
||||||
--compress --compress-choice=zstd \
|
|
||||||
--partial --progress \
|
|
||||||
--recursive \
|
|
||||||
--verbose \
|
|
||||||
./dist/* n001.fsn.p:/storage/christoph-heiss-at/public
|
|
|
@ -40,6 +40,11 @@ function buildProdHtml() {
|
||||||
.pipe(gulp.dest('dist/'))
|
.pipe(gulp.dest('dist/'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function copyProdPublic() {
|
||||||
|
return gulp.src('public/*')
|
||||||
|
.pipe(gulp.dest('dist/'));
|
||||||
|
}
|
||||||
|
|
||||||
function buildDevCss() {
|
function buildDevCss() {
|
||||||
return gulp.src('src/*.scss')
|
return gulp.src('src/*.scss')
|
||||||
.pipe(sass.sync().on('error', sass.logError))
|
.pipe(sass.sync().on('error', sass.logError))
|
||||||
|
@ -67,4 +72,4 @@ function startDevServer() {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.dev = gulp.series(cleanDist, buildDevCss, buildDevHtml, startDevServer);
|
exports.dev = gulp.series(cleanDist, buildDevCss, buildDevHtml, startDevServer);
|
||||||
exports.default = gulp.series(cleanDist, buildProdHtml);
|
exports.default = gulp.series(cleanDist, buildProdHtml, copyProdPublic);
|
||||||
|
|
2165
package-lock.json
generated
2165
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -24,16 +24,17 @@
|
||||||
"gulp-purgecss": "^4.1.3",
|
"gulp-purgecss": "^4.1.3",
|
||||||
"gulp-sass": "^5.1.0",
|
"gulp-sass": "^5.1.0",
|
||||||
"merge-stream": "^2.0.0",
|
"merge-stream": "^2.0.0",
|
||||||
"sass": "^1.52.2"
|
"sass": "^1.52.2",
|
||||||
|
"stylelint": "^14.11.0",
|
||||||
|
"stylelint-config-standard-scss": "^5.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16"
|
"node": ">=16"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "gulp dev",
|
"dev": "gulp dev",
|
||||||
"prod": "gulp",
|
"build": "gulp",
|
||||||
"lint:sass": "sass-lint -v -q",
|
"lint:scss": "stylelint src/*.scss"
|
||||||
"deploy": "./deploy.sh"
|
|
||||||
},
|
},
|
||||||
"target": "web"
|
"target": "web"
|
||||||
}
|
}
|
||||||
|
|
28
src/app.scss
28
src/app.scss
|
@ -1,35 +1,37 @@
|
||||||
@import 'sp';
|
@import 'sp';
|
||||||
|
|
||||||
|
$white: #fff;
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
font-size: 1.3em;
|
font-size: 1.3em;
|
||||||
max-width: 45em;
|
max-width: 45em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 768px) {
|
@media only screen and (max-width: 768px) {
|
||||||
body {
|
body {
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
list-style-type: '*';
|
list-style-type: '*';
|
||||||
}
|
}
|
||||||
|
|
||||||
li {
|
li {
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
margin-top: 4em;
|
border-top: 1px $white;
|
||||||
border-top: 1px #fff;
|
float: right;
|
||||||
float: right;
|
margin-top: 4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
a:visited {
|
a:visited {
|
||||||
color: #9bf;
|
color: #9bf;
|
||||||
}
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue