Implemented .env file and integrated env variables into production via production.env and the dotenv npm module

This commit is contained in:
2024-08-03 11:42:23 +03:00
parent 0fc7a2f22e
commit 50f6878502
5 changed files with 26 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ RUN npm install
COPY . . COPY . .
RUN npm run build RUN npm run build --env-file=production.env
RUN npm prune --omit=dev RUN npm prune --omit=dev
FROM node:22.5.1-alpine AS deployer FROM node:22.5.1-alpine AS deployer

View File

@@ -7,6 +7,9 @@
"": { "": {
"name": "personal-website", "name": "personal-website",
"version": "0.0.1", "version": "0.0.1",
"dependencies": {
"dotenv": "^16.4.5"
},
"devDependencies": { "devDependencies": {
"@sveltejs/adapter-node": "^5.2.0", "@sveltejs/adapter-node": "^5.2.0",
"@sveltejs/kit": "^2.0.0", "@sveltejs/kit": "^2.0.0",
@@ -1498,6 +1501,18 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/dotenv": {
"version": "16.4.5",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/eastasianwidth": { "node_modules/eastasianwidth": {
"version": "0.2.0", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",

View File

@@ -23,5 +23,8 @@
"svelte": "^4.2.7", "svelte": "^4.2.7",
"vite": "^5.0.3" "vite": "^5.0.3"
}, },
"type": "module" "type": "module",
"dependencies": {
"dotenv": "^16.4.5"
}
} }

0
frontend/production.env Normal file
View File

View File

@@ -1,2 +1,8 @@
<script>
import { PUBLIC_TEST } from '$env/static/public'
</script>
<h1>Welcome to SvelteKit</h1> <h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p> <p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
<p>{PUBLIC_TEST}</p>