From e2eb77c3b91095bfcdfb64c933046c380db0763f Mon Sep 17 00:00:00 2001 From: Mahmoud Emad Date: Sun, 11 May 2025 17:59:50 +0300 Subject: [PATCH] feat: Add Dockerfile and simplify install script - Add a Dockerfile for easy building and running of the application. - Simplify the install.sh script by removing unnecessary steps and hardcoded values. The installation of Tailwind CSS and Shadcn UI is now handled within the application. This allows for greater flexibility and simplifies the process. - Use environment variables for HOST and PORT, providing defaults. --- Dockerfile | 24 +++++++++++++++++ install.sh | 75 ++++++++++++++++++++++++++---------------------------- run.sh | 8 ++++-- 3 files changed, 66 insertions(+), 41 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fe06c99 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# Use a base image with Bun +FROM oven/bun:latest + +# Set working directory +WORKDIR /app + +# Copy the entire project +COPY . . + +# Make the scripts executable +RUN chmod +x install.sh run.sh + +# Run the install script to set up dependencies +RUN ./install.sh + +# Set environment variables with defaults +ENV HOST=0.0.0.0 +ENV PORT=3000 + +# Expose the port +EXPOSE ${PORT} + +# Run the application +CMD ["./run.sh"] \ No newline at end of file diff --git a/install.sh b/install.sh index d52a218..450234b 100755 --- a/install.sh +++ b/install.sh @@ -15,54 +15,51 @@ else echo "Bun is already installed." fi -# Install Svelte with Bun and Vite -echo "Installing Svelte with Bun and Vite..." -bun create vite sweb --template svelte-ts - -# Change into the new app directory +# Change into the existing app directory +echo "Changing to the sweb directory..." cd sweb # Install dependencies bun install -# Install Tailwind CSS and dependencies -echo "Installing Tailwind CSS and dependencies..." -bun add -D tailwindcss postcss autoprefixer +# # Install Tailwind CSS and dependencies +# echo "Installing Tailwind CSS and dependencies..." +# bun add -D tailwindcss postcss autoprefixer -# Initialize Tailwind CSS -echo "Initializing Tailwind CSS..." -bunx tailwindcss init -p +# # Initialize Tailwind CSS +# echo "Initializing Tailwind CSS..." +# bunx tailwindcss init -p -# Configure Tailwind CSS -echo "Configuring Tailwind CSS..." -# Modify tailwind.config.js -cat << EOF > tailwind.config.js -/** @type {import('tailwindcss').Config} */ -export default { - content: [ - './src/**/*.{html,js,svelte,ts}', - ], - theme: { - extend: {}, - }, - plugins: [], -} -EOF +# # Configure Tailwind CSS +# echo "Configuring Tailwind CSS..." +# # Modify tailwind.config.js +# cat << EOF > tailwind.config.js +# /** @type {import('tailwindcss').Config} */ +# export default { +# content: [ +# './src/**/*.{html,js,svelte,ts}', +# ], +# theme: { +# extend: {}, +# }, +# plugins: [], +# } +# EOF -# Add Tailwind directives to app.css -echo "Adding Tailwind directives to app.css..." -cat << EOF > src/app.css -@tailwind base; -@tailwind components; -@tailwind utilities; +# # Add Tailwind directives to app.css +# echo "Adding Tailwind directives to app.css..." +# cat << EOF > src/app.css +# @tailwind base; +# @tailwind components; +# @tailwind utilities; -$(cat src/app.css) -EOF +# $(cat src/app.css) +# EOF -# Install Shadcn for Svelte -echo "Installing Shadcn for Svelte..." -bun install lucide-svelte -# Attempting to run Shadcn Svelte init non-interactively by providing the components alias. -bunx shadcn-svelte init --style default --base-color slate --css src/app.css --tailwind-config tailwind.config.js --components-alias '$lib/components/ui' +# # Install Shadcn for Svelte +# echo "Installing Shadcn for Svelte..." +# bun install lucide-svelte +# # Attempting to run Shadcn Svelte init non-interactively by providing the components alias. +# bunx shadcn-svelte init --style default --base-color slate --css src/app.css --tailwind-config tailwind.config.js --components-alias '$lib/components/ui' diff --git a/run.sh b/run.sh index 356ada4..947f2ed 100755 --- a/run.sh +++ b/run.sh @@ -1,7 +1,11 @@ #!/bin/bash +# Set default values for HOST and PORT if not provided +HOST=${HOST:-0.0.0.0} +PORT=${PORT:-3000} + # Change to the Svelte app directory cd sweb -# Run the development server -bun run dev \ No newline at end of file +# Run the development server with the specified host and port +bun run dev -- --host $HOST --port $PORT \ No newline at end of file