Properly do staging

This commit is contained in:
DutchEllie 2022-07-13 13:12:25 +02:00
parent b78e015a95
commit 0e9e8c6085
Signed by: DutchEllie
SSH Key Fingerprint: SHA256:dKq6ZSgN5E3Viqrw/+xAdf2VdR6hdRGNyrYqXXwfjTY
4 changed files with 28 additions and 7 deletions

View File

@ -4,6 +4,7 @@
"scripts": { "scripts": {
"dev": "vite dev", "dev": "vite dev",
"build": "vite build", "build": "vite build",
"staging": "vite build --mode staging",
"package": "svelte-kit package", "package": "svelte-kit package",
"preview": "vite preview", "preview": "vite preview",
"prepare": "svelte-kit sync", "prepare": "svelte-kit sync",

View File

@ -15,9 +15,11 @@
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { sha256 } from 'js-sha256'; import { sha256 } from 'js-sha256';
import GuestbookEntry from './guestbook/guestbook-entry.svelte'; import GuestbookEntry from './guestbook/guestbook-entry.svelte';
import { page } from '$app/stores'; import { mode } from '$app/env';
import { comment } from 'postcss';
//const ApiURL = dev ? 'https://api.quenten.nl/api/testing' : 'https://api.quenten.nl/api';
//const ApiURL = import.meta.env.APIURL;
const ApiURL = mode == 'production' ? 'https://api.quenten.nl/api' : 'https://api.quenten.nl/api/testing';
let showError = false; let showError = false;
let errorTitle = 'Error'; let errorTitle = 'Error';
let errorMessage = 'Error message'; let errorMessage = 'Error message';
@ -58,7 +60,7 @@ import { comment } from 'postcss';
}; };
const jsonData = JSON.stringify(data); const jsonData = JSON.stringify(data);
const res = await fetch('https://api.quenten.nl/api/testing/comment', { const res = await fetch(ApiURL + '/comment', {
method: 'POST', method: 'POST',
body: jsonData body: jsonData
}); });
@ -91,7 +93,7 @@ import { comment } from 'postcss';
return; return;
} }
let newHash = await fetch('https://api.quenten.nl/api/testing/commenthash') let newHash = await fetch(ApiURL + '/commenthash')
.then((res) => res.text()) .then((res) => res.text())
.then((t) => { .then((t) => {
return t; return t;
@ -107,7 +109,7 @@ import { comment } from 'postcss';
async function fetchComments() { async function fetchComments() {
let comments: Comment[]; let comments: Comment[];
comments = await fetch('https://api.quenten.nl/api/testing/comment') comments = await fetch(ApiURL + '/comment')
.then((res) => res.json()) .then((res) => res.json())
.then((data) => { .then((data) => {
return data; return data;

18
staging.Dockerfile Normal file
View File

@ -0,0 +1,18 @@
FROM node:18.2.0-alpine
WORKDIR /app
COPY . .
RUN npm ci
RUN npm audit fix
RUN npm run staging
FROM node:18.2.0-alpine
WORKDIR /app
COPY --from=0 /app/package*.json ./
RUN npm ci --ignore-scripts
RUN npm audit fix
COPY --from=0 /app/build ./
EXPOSE 3000
CMD ["node", "./index.js"]

View File

@ -2,7 +2,7 @@ import { sveltekit } from '@sveltejs/kit/vite';
/** @type {import('vite').UserConfig} */ /** @type {import('vite').UserConfig} */
const config = { const config = {
plugins: [sveltekit()] plugins: [sveltekit()],
}; };
export default config; export default config;