From 958c0512988f26d1622dac7958197a6339a571b7 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Tue, 5 Mar 2019 01:21:52 +0100 Subject: [PATCH] Rauchmelder --- .drone.yml | 48 ++++++++++++++++++++++++++++++ .gitignore | 5 ++++ LICENSE | 21 +++++++++++++ docker-compose.prod.yml | 16 ++++++++++ docker-compose.yml | 10 +++++++ package.json | 30 +++++++++++++++++++ src/App.styl | 42 ++++++++++++++++++++++++++ src/App.tsx | 31 ++++++++++++++++++++ src/index.html | 14 +++++++++ src/index.tsx | 7 +++++ tsconfig.json | 60 +++++++++++++++++++++++++++++++++++++ webpack.config.js | 65 +++++++++++++++++++++++++++++++++++++++++ 12 files changed, 349 insertions(+) create mode 100644 .drone.yml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 docker-compose.prod.yml create mode 100644 docker-compose.yml create mode 100755 package.json create mode 100644 src/App.styl create mode 100644 src/App.tsx create mode 100755 src/index.html create mode 100755 src/index.tsx create mode 100644 tsconfig.json create mode 100755 webpack.config.js diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..faf176d --- /dev/null +++ b/.drone.yml @@ -0,0 +1,48 @@ +kind: pipeline +name: default + +steps: + - name: install + image: node:11-alpine + commands: + - node -v + - npm -v + - npm i + + - name: build + image: node:11-alpine + commands: + - npm run build:prod + + - name: copy + image: appleboy/drone-scp + environment: + PLUGIN_KEY: + from_secret: ssh_key + settings: + host: nicco.io + username: root + port: 1312 + target: /srv/web/home + source: + - ./public + - ./docker-compose.yml + - ./docker-compose.prod.yml + when: + event: push + branch: master + + + - name: run + image: appleboy/drone-ssh + environment: + PLUGIN_KEY: + from_secret: ssh_key + settings: + host: nicco.io + username: root + port: 1312 + script: + - cd /srv/web/home + - docker-compose -f docker-compose.yml -f docker-compose.prod.yml down + - docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..08c9401 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules +public + +.idea +.vscode \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2d82f81 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Nicco + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..b15370f --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,16 @@ +version: '3' + +services: + home: + networks: + - traefik + labels: + - traefik.enable=true + - traefik.port=80 + - traefik.docker.network=traefik + - traefik.backend=rauchmelder + - traefik.frontend.rule=Host:rauchmelder.nicco.io + +networks: + traefik: + external: true \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7469a30 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3' + +services: + home: + image: nginx:alpine + restart: always + ports: + - 80 + volumes: + - ./public:/usr/share/nginx/html:ro \ No newline at end of file diff --git a/package.json b/package.json new file mode 100755 index 0000000..ece7682 --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "private": true, + "scripts": { + "build:dev": "webpack -d", + "build:prod": "webpack -p", + "dev": "webpack-dev-server -d" + }, + "dependencies": { + "moment": "^2.24.0", + "react": "^16.8", + "react-dom": "^16.8", + "react-fittext": "^1.0.0" + }, + "devDependencies": { + "@types/react": "^16.8", + "@types/react-dom": "^16.8", + "awesome-typescript-loader": "^5", + "css-loader": "^2", + "file-loader": "^3", + "html-webpack-plugin": "^3", + "mini-css-extract-plugin": "^0.5.0", + "style-loader": "^0", + "stylus": "^0", + "stylus-loader": "^3", + "typescript": "^3.3.3", + "webpack": "^4", + "webpack-cli": "^3", + "webpack-dev-server": "^3.1.14" + } +} diff --git a/src/App.styl b/src/App.styl new file mode 100644 index 0000000..74003ea --- /dev/null +++ b/src/App.styl @@ -0,0 +1,42 @@ +@import url('https://fonts.googleapis.com/css?family=PT+Sans') + +* + box-sizing border-box + +html +body +#root + margin 0 + padding 0 + width 100vw + height 100vh + overflow hidden + font-family 'PT Sans', sans-serif + font-weight bold + +#app + height: 100% + width: 100% + //background-color #eeffee + background linear-gradient(45deg, #111, #222) + color #fff + display flex + justify-content center + align-items center + text-align center + + @media (min-width: 0px) + #text + font-size 3em + #title + font-size 2em + @media (min-width: 900px) + #text + font-size 4em + #title + font-size 3em + @media (min-width: 1200px) + #text + font-size 5em + #title + font-size 4em diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 0000000..4883f74 --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,31 @@ +import moment from 'moment' +import React, { useEffect, useState } from 'react' +// @ts-ignore + + +const App: React.FC = () => { + + const [refresh, setRefresh] = useState(0) + + const gloryTime = moment('2019-02-12').unix() + const now = Date.now() / 1000 | 0 + const delta = moment.duration(now - gloryTime, 'seconds') + + useEffect(()=> { + setTimeout(()=> setRefresh(refresh + 1), 1000) + }, [refresh]) + + return
+
+
Rauchmelder 💨
+
+
+ {delta.humanize()} +
+ {delta.asSeconds()} +
+
+
+} + +export default App \ No newline at end of file diff --git a/src/index.html b/src/index.html new file mode 100755 index 0000000..402f59f --- /dev/null +++ b/src/index.html @@ -0,0 +1,14 @@ + + + + + 💨 + + + + + +
+ + + \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx new file mode 100755 index 0000000..7f9a95d --- /dev/null +++ b/src/index.tsx @@ -0,0 +1,7 @@ +import React from 'react' +import ReactDOM from 'react-dom' + +import './App.styl' +import App from './App' + +ReactDOM.render(, document.getElementById('root')) \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..4d6e7d8 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,60 @@ +{ + "compilerOptions": { + /* Basic Options */ + "target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + // "lib": [], /* Specify library files to be included in the compilation. */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "composite": true, /* Enable project compilation */ + "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true, /* Enable all strict type-checking options. */ + "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + "strictNullChecks": true, /* Enable strict null checks. */ + "strictFunctionTypes": true, /* Enable strict checking of function types. */ + "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ + "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ + "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + + /* Source Map Options */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js new file mode 100755 index 0000000..1d822ae --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,65 @@ +const path = require('path') + +const HtmlWebpackPlugin = require('html-webpack-plugin') +const MiniCssExtractPlugin = require('mini-css-extract-plugin') + +module.exports = { + entry: [ + './index.tsx' + ], + output: { + filename: 'bundle.js', + path: path.resolve(__dirname, 'public') + }, + resolve: { + extensions: ['.js', '.jsx', '.ts', '.tsx'] + }, + context: path.resolve(__dirname, 'src'), + devServer: { + contentBase: path.resolve(__dirname, 'public/assets'), + open: true, + }, + plugins: [ + new HtmlWebpackPlugin({ + template: 'index.html' + }), + new MiniCssExtractPlugin({ + filename: 'bundle.css' + }) + ], + stats: { + assets: true, + assetsSort: 'size', + all: false, + errors: true, + colors: true, + performance: true, + timings: true, + }, + module: { + rules: [{ + test: /\.tsx?$/, + loader: 'awesome-typescript-loader', + }, + // { + // test: /\.html$/, + // use: ['html-loader'] + // }, + { + test: /\.css$/, + use: [MiniCssExtractPlugin.loader, 'css-loader'] + }, { + test: /\.styl$/, + use: [MiniCssExtractPlugin.loader, 'css-loader', 'stylus-loader'], + }, { + test: /\.(jpg|png|gif|svg|woff2?|ttf|eot|svg|otf)$/, + use: [{ + loader: 'file-loader', + options: { + name: '[name].[ext]', + outputPath: './assets/', + }, + }], + }] + } +} \ No newline at end of file