Deploy ..

This commit is contained in:
Hubert Van De Walle 2020-06-26 02:23:06 +02:00
parent 67915246ba
commit 8f9dc0d9ce
18 changed files with 469 additions and 362 deletions

View File

@ -1,6 +1,9 @@
MYSQL_ROOT_PASSWORD=
MYSQL_HOST=db
MYSQL_DATABASE=
MYSQL_USER=
MYSQL_PASSWORD=
JWT_SECRET=
CORS=false
JWT_REFRESH_SECRET=
CORS=false
PORT=8081

View File

@ -4,7 +4,7 @@
-Date
Strict-Transport-Security "max-age=31536000; includeSubDomains"
Feature-Policy "geolocation none;midi none;notifications none;push none;sync-xhr none;microphone none;camera none;magnetometer none;gyroscope none;speaker self;vibrate none;fullscreen self;payment none;"
Feature-Policy "geolocation none; midi none; notifications none; push none; sync-xhr none; microphone none; camera none; magnetometer none; gyroscope none; speaker self; vibrate none; fullscreen self; payment none"
X-Content-Type-Options "nosniff"
X-Frame-Options "DENY"
X-XSS-Protection "1; mode=block"
@ -12,45 +12,56 @@
}
}
simplenotes.be {
@static {
path *.css *.js
file
(common) {
@ignore {
path *.php
}
respond @ignore "no" 404
encode gzip
}
(nuxt) {
@nuxt {
path /_nuxt/*
}
@fonts {
path *.woff *.woff2
file
}
header @nuxt Cache-Control "public, max-age=31536000" # 1 year
}
simplenotes.be {
import security
import nuxt
import common
@404 {
expression {http.error.status_code} == 404
}
route /* {
file_server
}
handle_errors {
rewrite @404 /404.html
file_server
import security
}
route /api/* {
uri strip_prefix /api
reverse_proxy http://api:8081
route /* {
file_server
}
route /api/* {
uri strip_prefix /api
reverse_proxy http://localhost:8081
}
header @static Cache-Control "public, max-age=31536000" # 1 year
header @fonts Cache-Control "public, max-age=604800" # 7 days
header Content-Security-Policy "default-src 'self' 'unsafe-inline';"
encode gzip
root * /site
log
root * /var/www/simplenotes.be
log {
output file /var/log/www/simplenotes.be.json
format json
}
import security
}
www.simplenotes.be {
@ -58,9 +69,36 @@ www.simplenotes.be {
}
docs.simplenotes.be {
file_server
root * /docs
import security
import common
file_server
root * /var/www/docs.simplenotes.be
log {
output file /var/log/www/docs.simplenotes.be.json
format json
}
header Content-Security-Policy "default-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net;"
}
portfolio.simplenotes.be {
import security
import common
import nuxt
file_server
root * /var/www/portfolio.simplenotes.be
log {
output file /var/log/www/portfolio.simplenotes.be.json
format json
}
header @static Cache-Control "public, max-age=31536000" # 1 year
# header Content-Security-Policy "default-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net;"
}

View File

@ -10,7 +10,7 @@ COPY api/resources resources
COPY api/src src
COPY api/test test
RUN mvn package
RUN mvn package -DskipTests
FROM openjdk:14-alpine
@ -25,4 +25,4 @@ USER $APPLICATION_USER
COPY --from=builder /tmp/target/api-*-jar-with-dependencies.jar /app/notes-api.jar
WORKDIR /app
CMD ["java", "-server", "-XX:+UnlockExperimentalVMOptions", "-XX:InitialRAMFraction=2", "-XX:MinRAMFraction=2", "-XX:MaxRAMFraction=2", "-XX:+UseG1GC", "-XX:MaxGCPauseMillis=100", "-XX:+UseStringDeduplication", "-jar", "notes-api.jar"]
CMD ["java", "-server", "-XX:+UnlockExperimentalVMOptions", "-XX:InitialRAMFraction=2", "-XX:MinRAMFraction=2", "-XX:MaxRAMFraction=2", "-XX:+UseG1GC", "-XX:MaxGCPauseMillis=100", "-XX:+UseStringDeduplication", "-jar", "notes-api.jar"]

View File

@ -1,19 +0,0 @@
## Docker multi-stage build
## Generate api documentation
FROM quay.io/bukalapak/snowboard AS docbuilder
RUN mkdir /out
COPY api-doc /doc
RUN /app/packages/snowboard/bin/run html api.apib -o /out
## Generate website
FROM node:latest AS builder
COPY frontend /app
WORKDIR /app
RUN yarn install && yarn run generate
## Main image
FROM caddy:2.0.0
COPY Caddyfile /etc/caddy/Caddyfile
COPY --from=docbuilder /out /docs
COPY --from=builder /app/dist /site

View File

@ -7,7 +7,7 @@ database:
server:
host: 0.0.0.0
port: 8081
port: ${PORT:-8081}
cors: ${CORS:-true}
jwt:

View File

@ -6,23 +6,23 @@ import be.vandewalleh.migrations.Migration
import be.vandewalleh.routing.noteRoutes
import be.vandewalleh.routing.tagsRoute
import be.vandewalleh.routing.userRoutes
import com.sksamuel.hoplite.fp.valid
import io.ktor.application.*
import io.ktor.auth.*
import io.ktor.routing.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import me.liuwj.ktorm.database.*
import org.kodein.di.Kodein
import org.kodein.di.description
import org.kodein.di.generic.instance
import org.kodein.di.generic.with
import org.slf4j.Logger
fun main() {
fun main(args: Array<String>) {
val kodein = Kodein{
import(mainModule)
constant("config file") with "/application.prod.yaml" // FIXME
}
val config by kodein.instance<Config>()

View File

@ -9,7 +9,6 @@ import org.kodein.di.Kodein
import org.kodein.di.generic.bind
import org.kodein.di.generic.instance
import org.kodein.di.generic.singleton
import org.kodein.di.generic.with
import java.util.concurrent.TimeUnit
import javax.sql.DataSource
@ -17,7 +16,6 @@ import javax.sql.DataSource
* [Kodein] controller module containing the app configuration
*/
val configurationModule = Kodein.Module(name = "Configuration") {
constant("config file") with "/application.dev.yaml" // FIXME
bind() from singleton {
val configFile by this.kodein.instance<String>(tag = "config file")
ConfigLoader().loadConfigOrThrow<Config>(configFile)

View File

@ -2,20 +2,6 @@ version: '2.2'
services:
caddy:
build:
dockerfile: Dockerfile.caddy
context: .
container_name: notes-caddy
environment:
- TZ=Europe/Brussels
volumes:
- notes-caddy-data:/data
- notes-caddy-config:/config
ports:
- 80:80
- 443:443
api:
build:
dockerfile: Dockerfile.api

View File

@ -1,20 +0,0 @@
:8080
root dist
file_server {
# If we visit /404.html directly we receive a 404 response, and not a 200.
hide 404.html
}
encode gzip
handle_errors {
@404 {
expression {http.error.status_code} == 404
}
rewrite @404 /404.html
file_server
}
log {
format single_field common_log
}

View File

@ -5,8 +5,7 @@
font-weight: 400;
font-display: swap;
src: local('Roboto'), local('Roboto-Regular'),
url('/fonts/roboto-v20-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('/fonts/roboto-v20-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
url('./fonts/roboto-v20-latin-regular.woff2') format('woff2')
}

View File

@ -116,10 +116,6 @@ export default {
this.$vuetify.theme.dark = !this.$vuetify.theme.dark
const theme = this.$vuetify.theme.dark ? 'dark' : 'light'
localStorage.setItem('theme', theme)
this.$cookies.set('theme', theme, {
path: '/',
maxAge: 60 * 60 * 24 * 7,
})
},
},
}

View File

@ -1,9 +1,4 @@
import colors from 'vuetify/es5/util/colors'
import { config } from 'dotenv'
const env = config().parsed
export default {
export default ({ command }) => ({
mode: 'universal',
/*
** Headers of the page
@ -26,16 +21,7 @@ export default {
content: process.env.npm_package_description || '',
},
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{
rel: 'preload',
href: '/fonts/roboto-v20-latin-regular.woff2',
as: 'font',
type: 'font/woff2',
crossorigin: 'anonymous',
},
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
/*
** Customize the progress-bar color
@ -64,9 +50,9 @@ export default {
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios',
// Doc: https://github.com/nuxt-community/dotenv-module
'@nuxtjs/dotenv',
'@nuxtjs/auth',
'cookie-universal-nuxt',
// Doc: https://github.com/nuxt-community/robots-module
'@nuxtjs/robots',
],
/*
** Axios module configuration
@ -74,8 +60,8 @@ export default {
*/
axios: {},
env: {
API_HOST: env.API_HOST,
publicRuntimeConfig: {
API_HOST: process.env.API_HOST,
},
auth: {
@ -85,12 +71,7 @@ export default {
home: '/notes',
},
watchLoggedIn: true,
cookie: {
prefix: 'auth.',
options: {
path: '/',
},
},
cookie: !command.includes('generate'),
strategies: {
_scheme: 'local',
_name: 'local',
@ -190,4 +171,17 @@ export default {
components: true,
telemetry: false,
}
robots: {
UserAgent: '*',
Disallow: '/',
},
render: {
bundleRenderer: {
shouldPrefetch: () => false,
shouldPreload: (_, asType) =>
['font', 'script', 'style'].includes(asType),
},
},
})

View File

@ -15,9 +15,8 @@
"dependencies": {
"@nuxtjs/auth": "^4.9.1",
"@nuxtjs/axios": "^5.3.6",
"@nuxtjs/dotenv": "^1.4.0",
"@nuxtjs/robots": "^2.4.2",
"@starptech/prettyhtml-hast-to-html": "^0.10.0",
"cookie-universal-nuxt": "^2.1.4",
"nuxt": "^2.13.0",
"remark": "^12.0.0",
"remark-breaks": "^1.0.5",

View File

@ -43,7 +43,7 @@ export default {
...mapGetters('notes', ['isEmpty']),
},
mounted() {
if (!this.initialized) this.load()
if (!this.isInitialized) this.load()
},
methods: {
...mapActions('notes', ['load']),

File diff suppressed because it is too large Load Diff

View File

@ -9,5 +9,4 @@ check_installed() {
check_installed docker-compose
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 --build