-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from dqualizer/Add-Docker-Build
Add docker build
- Loading branch information
Showing
19 changed files
with
178 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules / | ||
dist | ||
test.json | ||
Dockerfile | ||
npm - debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
# Please provide the Url for dqApi | ||
VITE_BACKEND_URL=http://localhost:8099/api/v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
FROM --platform=$BUILDPLATFORM node:19-alpine AS base | ||
|
||
FROM base AS deps | ||
RUN apk add --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ | ||
RUN \ | ||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ | ||
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ | ||
elif [ -f package-lock.json ]; then npm ci; \ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
|
||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
RUN npm run build | ||
|
||
FROM --platform=$BUILDPLATFORM nginx:1.22-alpine AS runtime | ||
COPY --from=builder /app/dist/app /usr/share/nginx/html | ||
|
||
# Adding the env-File and the Shell-Script | ||
WORKDIR /usr/share/nginx/html | ||
COPY ./env.sh . | ||
COPY .env . | ||
|
||
COPY entrypoint.sh /usr/bin/ | ||
|
||
# Adding nginx-config | ||
COPY nginx.conf /etc/nginx/conf.d/default.conf | ||
|
||
RUN chmod +x /usr/bin/entrypoint.sh | ||
|
||
# Add bash | ||
RUN apk add --no-cache bash | ||
|
||
RUN chmod +x env.sh | ||
|
||
# Executing the Shell-Skript | ||
CMD ["entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
# Check if the VITE_BACKEND_URL environment variable is set | ||
if [ -z "$VITE_BACKEND_URL" ]; then | ||
echo "Error: | ||
The environment variable VITE_BACKEND_URL is not set. | ||
Please enter a valid URL, for example, '-e VITE_BACKEND_URL=http://localhost:8080' on 'docker run'." | ||
exit 1 | ||
fi | ||
|
||
# Run the env.sh script | ||
source /usr/share/nginx/html/env.sh | ||
|
||
# Start nginx | ||
nginx -g "daemon off;" -c "/data/conf/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# Recreate config file | ||
rm -rf ./env-config.js | ||
touch ./env-config.js | ||
|
||
# Add assignment - window._env_ will contain all Environment-Variables, defined in .env | ||
echo "window._env_ = {" >> ./env-config.js | ||
|
||
# Read each line in .env file | ||
# Each line represents key=value pairs | ||
while read -r line || [[ -n "$line" ]]; | ||
do | ||
# Split env variables by character `=` | ||
if printf '%s\n' "$line" | grep -q -e '='; then | ||
varname=$(printf '%s\n' "$line" | sed -e 's/=.*//') | ||
varvalue=$(printf '%s\n' "$line" | sed -e 's/^[^=]*=//') | ||
fi | ||
|
||
# Read value of current variable if exists as Environment variable | ||
value=$(printf '%s\n' "${!varname}") | ||
# Otherwise use value from .env file | ||
[[ -z $value ]] && value=${varvalue} | ||
|
||
# Append configuration property to JS file | ||
echo " $varname: \"$value\"," >> ./env-config.js | ||
done < .env | ||
echo "}" >> ./env-config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
server { | ||
listen 80; | ||
server_name localhost; | ||
|
||
#access_log /var/log/nginx/host.access.log main; | ||
|
||
location / { | ||
root /usr/share/nginx/html; | ||
index index.html index.html; | ||
try_files $uri $uri/ /index.html; | ||
} | ||
|
||
#error_page 404 /404.html; | ||
|
||
# redirect server error pages to the static page /50x.html | ||
# | ||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
root /usr/share/nginx/html; | ||
} | ||
|
||
# proxy the PHP scripts to Apache listening on 127.0.0.1:80 | ||
# | ||
#location ~ \.php$ { | ||
# proxy_pass http://127.0.0.1; | ||
#} | ||
|
||
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | ||
# | ||
#location ~ \.php$ { | ||
# root html; | ||
# fastcgi_pass 127.0.0.1:9000; | ||
# fastcgi_index index.php; | ||
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; | ||
# include fastcgi_params; | ||
#} | ||
|
||
# deny access to .htaccess files, if Apache's document root | ||
# concurs with nginx's one | ||
# | ||
#location ~ /\.ht { | ||
# deny all; | ||
#} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import dotenv from 'dotenv'; | ||
dotenv.config(); | ||
|
||
import { defineConfig, loadEnv } from 'vite'; | ||
import react from '@vitejs/plugin-react'; | ||
|
||
|
||
export default ({ mode }) => { | ||
const env = { ...process.env, ...loadEnv(mode, process.cwd(), '') }; | ||
return defineConfig({ | ||
plugins: [react()], | ||
build: { | ||
outDir: 'dist/app', | ||
}, | ||
define: { | ||
__VITE_BACKEND_URL__: JSON.stringify(env.VITE_BACKEND_URL) | ||
}, | ||
}) | ||
|
||
}; |
This file was deleted.
Oops, something went wrong.