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
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
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
|
||||
|
||||
COPY . .
|
||||
ENV NODE_ENV production
|
||||
RUN npm clean-install && npm run prod
|
||||
RUN npm clean-install && npm run build
|
||||
|
||||
FROM nginx:1.23-alpine AS runner
|
||||
|
||||
|
@ -21,7 +20,7 @@ server {\
|
|||
root /var/www/html;\
|
||||
try_files /index.html =404;\
|
||||
\
|
||||
location ~ ^/(robots.txt)$ {\
|
||||
location ~ ^/(favicon.ico|robots.txt)$ {\
|
||||
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/'))
|
||||
}
|
||||
|
||||
function copyProdPublic() {
|
||||
return gulp.src('public/*')
|
||||
.pipe(gulp.dest('dist/'));
|
||||
}
|
||||
|
||||
function buildDevCss() {
|
||||
return gulp.src('src/*.scss')
|
||||
.pipe(sass.sync().on('error', sass.logError))
|
||||
|
@ -67,4 +72,4 @@ function 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-sass": "^5.1.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": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "gulp dev",
|
||||
"prod": "gulp",
|
||||
"lint:sass": "sass-lint -v -q",
|
||||
"deploy": "./deploy.sh"
|
||||
"build": "gulp",
|
||||
"lint:scss": "stylelint src/*.scss"
|
||||
},
|
||||
"target": "web"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
@import 'sp';
|
||||
|
||||
$white: #fff;
|
||||
|
||||
body {
|
||||
font-family: monospace;
|
||||
font-size: 1.3em;
|
||||
|
@ -21,9 +23,9 @@ li {
|
|||
}
|
||||
|
||||
footer {
|
||||
margin-top: 4em;
|
||||
border-top: 1px #fff;
|
||||
border-top: 1px $white;
|
||||
float: right;
|
||||
margin-top: 4em;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
|
|
Loading…
Reference in a new issue