wepee commited on
Commit
4065739
·
1 Parent(s): f83de4b

fix: dockerfile

Browse files
Files changed (6) hide show
  1. .dockerignore +1 -0
  2. .env.docker +2 -0
  3. .env.example +0 -1
  4. Dockerfile +10 -12
  5. entrypoint.sh +4 -0
  6. vite.config.ts +5 -0
.dockerignore CHANGED
@@ -10,6 +10,7 @@ public/build
10
  .env
11
  .env.*
12
  !.env.example
 
13
 
14
  database/*.sqlite
15
  storage/framework/cache/data/*
 
10
  .env
11
  .env.*
12
  !.env.example
13
+ !.env.docker
14
 
15
  database/*.sqlite
16
  storage/framework/cache/data/*
.env.docker ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ RAG_API_BASE_URL=https://lifedebugger-raghub-sevima-test.hf.space/api/v1
2
+ VITE_APP_NAME="RAG Hub"
.env.example CHANGED
@@ -69,4 +69,3 @@ AWS_USE_PATH_STYLE_ENDPOINT=false
69
 
70
  VITE_APP_NAME="${APP_NAME}"
71
  RAG_API_BASE_URL=https://lifedebugger-raghub-sevima-test.hf.space/api/v1
72
- RAG_CHAT_API_MODE=direct
 
69
 
70
  VITE_APP_NAME="${APP_NAME}"
71
  RAG_API_BASE_URL=https://lifedebugger-raghub-sevima-test.hf.space/api/v1
 
Dockerfile CHANGED
@@ -1,11 +1,6 @@
1
  FROM php:8.4-cli
2
 
3
- ARG VITE_APP_NAME=Laravel
4
- ARG RAG_API_BASE_URL=https://lifedebugger-raghub-sevima-test.hf.space/api/v1
5
- ARG RAG_CHAT_API_MODE=direct
6
-
7
- ENV APP_NAME="${VITE_APP_NAME}" \
8
- APP_ENV=production \
9
  APP_DEBUG=false \
10
  APP_URL=http://localhost \
11
  LOG_CHANNEL=stderr \
@@ -14,10 +9,7 @@ ENV APP_NAME="${VITE_APP_NAME}" \
14
  CACHE_STORE=file \
15
  QUEUE_CONNECTION=sync \
16
  DB_CONNECTION=sqlite \
17
- PORT=7860 \
18
- RAG_API_BASE_URL="${RAG_API_BASE_URL}" \
19
- RAG_CHAT_API_MODE="${RAG_CHAT_API_MODE}" \
20
- VITE_APP_NAME="${VITE_APP_NAME}"
21
 
22
  RUN apt-get update && apt-get install -y \
23
  git unzip curl zip ca-certificates gnupg \
@@ -47,11 +39,17 @@ COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
47
  RUN useradd -m -u 1000 user
48
 
49
  ENV HOME=/home/user
 
50
  RUN mkdir -p /home/user/app && chown user:user /home/user/app
 
51
  WORKDIR /home/user/app
52
 
53
  COPY --chown=user:user . .
54
 
 
 
 
 
55
  USER user
56
 
57
  RUN composer install --no-dev --optimize-autoloader --no-interaction --no-scripts \
@@ -59,10 +57,10 @@ RUN composer install --no-dev --optimize-autoloader --no-interaction --no-script
59
  && php artisan config:clear \
60
  && php artisan route:clear \
61
  && npm ci \
62
- && npm run build \
63
  && rm -rf node_modules \
64
  && php artisan view:clear
65
 
66
  EXPOSE 7860
67
 
68
- CMD ["sh", "-c", "if [ -n \"$SPACE_HOST\" ] && [ \"$APP_URL\" = \"http://localhost\" ]; then export APP_URL=\"https://$SPACE_HOST\"; fi; if [ -n \"$SPACE_HOST\" ] && [ -z \"$ASSET_URL\" ]; then export ASSET_URL=\"https://$SPACE_HOST\"; fi; if [ -z \"$APP_KEY\" ]; then export APP_KEY=$(php artisan key:generate --show --no-interaction); fi; php artisan serve --host=0.0.0.0 --port=${PORT:-7860}"]
 
1
  FROM php:8.4-cli
2
 
3
+ ENV APP_ENV=production \
 
 
 
 
 
4
  APP_DEBUG=false \
5
  APP_URL=http://localhost \
6
  LOG_CHANNEL=stderr \
 
9
  CACHE_STORE=file \
10
  QUEUE_CONNECTION=sync \
11
  DB_CONNECTION=sqlite \
12
+ PORT=7860
 
 
 
13
 
14
  RUN apt-get update && apt-get install -y \
15
  git unzip curl zip ca-certificates gnupg \
 
39
  RUN useradd -m -u 1000 user
40
 
41
  ENV HOME=/home/user
42
+
43
  RUN mkdir -p /home/user/app && chown user:user /home/user/app
44
+
45
  WORKDIR /home/user/app
46
 
47
  COPY --chown=user:user . .
48
 
49
+ COPY entrypoint.sh /entrypoint.sh
50
+
51
+ RUN chmod +x /entrypoint.sh
52
+
53
  USER user
54
 
55
  RUN composer install --no-dev --optimize-autoloader --no-interaction --no-scripts \
 
57
  && php artisan config:clear \
58
  && php artisan route:clear \
59
  && npm ci \
60
+ && export $(grep -v '^#' .env.docker | xargs) && npm run build \
61
  && rm -rf node_modules \
62
  && php artisan view:clear
63
 
64
  EXPOSE 7860
65
 
66
+ ENTRYPOINT ["/entrypoint.sh"]
entrypoint.sh CHANGED
@@ -1,6 +1,10 @@
1
  #!/bin/sh
2
  set -e
3
 
 
 
 
 
4
  env | while IFS='=' read -r KEY VALUE; do
5
  case "$KEY" in
6
  *_FILE)
 
1
  #!/bin/sh
2
  set -e
3
 
4
+ if [ -f .env.docker ]; then
5
+ export $(grep -v '^#' .env.docker | xargs)
6
+ fi
7
+
8
  env | while IFS='=' read -r KEY VALUE; do
9
  case "$KEY" in
10
  *_FILE)
vite.config.ts CHANGED
@@ -7,6 +7,11 @@ import { bunny } from 'laravel-vite-plugin/fonts';
7
  import { defineConfig } from 'vite';
8
 
9
  export default defineConfig({
 
 
 
 
 
10
  plugins: [
11
  laravel({
12
  input: ['resources/css/app.css', 'resources/js/app.tsx'],
 
7
  import { defineConfig } from 'vite';
8
 
9
  export default defineConfig({
10
+ define: {
11
+ 'import.meta.env.VITE_RAG_API_BASE_URL': JSON.stringify(
12
+ process.env.VITE_RAG_API_BASE_URL ?? process.env.RAG_API_BASE_URL ?? '',
13
+ ),
14
+ },
15
  plugins: [
16
  laravel({
17
  input: ['resources/css/app.css', 'resources/js/app.tsx'],