mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
ci: improve first install
This commit is contained in:
@@ -25,6 +25,11 @@ RUN npm run build
|
||||
# Production stage
|
||||
FROM node:23-slim
|
||||
|
||||
# Default environment variables
|
||||
ENV UPLOAD_PATH=/app/uploads
|
||||
ENV NODE_ENV=production
|
||||
ENV DATABASE_URL=file:/app/data/db.sqlite
|
||||
|
||||
# Install required system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ghostscript \
|
||||
@@ -36,7 +41,7 @@ RUN apt-get update && apt-get install -y \
|
||||
WORKDIR /app
|
||||
|
||||
# Create upload directory and set permissions
|
||||
RUN mkdir -p /app/upload && chown -R node:node /app/upload
|
||||
RUN mkdir -p /app/upload
|
||||
|
||||
# Copy built assets from builder
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
|
||||
@@ -125,10 +125,8 @@ Deploy your own instance of TaxHacker with Vercel in just a few clicks:
|
||||
For server deployment, we provide a [Docker image](./Dockerfile) and [Docker Compose](./docker-compose.yml) files that makes setting up TaxHacker simple:
|
||||
|
||||
```bash
|
||||
# Download docker-compose.yml file
|
||||
curl -O https://raw.githubusercontent.com/vas3k/TaxHacker/main/docker-compose.yml
|
||||
|
||||
# Run it
|
||||
docker compose up
|
||||
```
|
||||
|
||||
@@ -191,13 +189,13 @@ npx prisma migrate dev && npx prisma generate
|
||||
# Seed the database with default data (optional)
|
||||
npm run seed
|
||||
|
||||
# Start the development server with Turbopack
|
||||
# Start the development server
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Visit `http://localhost:3000` to see your local instance of TaxHacker.
|
||||
|
||||
For a production build:
|
||||
For a production build, instead of `npm run dev` use the following commands:
|
||||
|
||||
```bash
|
||||
# Build the application
|
||||
|
||||
@@ -5,11 +5,9 @@ set -e
|
||||
echo "Running database migrations..."
|
||||
npx prisma migrate deploy
|
||||
|
||||
# Run database seeding if SEED_DATABASE is set to true
|
||||
if [ "$SEED_DATABASE" = "true" ]; then
|
||||
echo "Seeding database..."
|
||||
# Initialize database
|
||||
echo "Checking and seeding database if needed..."
|
||||
npm run seed
|
||||
fi
|
||||
|
||||
# Start the application
|
||||
echo "Starting the application..."
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"name": "taxhacker",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "next dev --turbopack",
|
||||
"build": "next build",
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import { PrismaClient } from "@prisma/client"
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
const DATABASE_URL = process.env.DATABASE_URL || "file:./db.sqlite"
|
||||
const prisma = new PrismaClient({
|
||||
datasources: {
|
||||
db: {
|
||||
url: DATABASE_URL,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const forceSeed = process.argv.includes("--force")
|
||||
|
||||
const settings = [
|
||||
{
|
||||
@@ -410,13 +420,19 @@ const fields = [
|
||||
},
|
||||
]
|
||||
|
||||
async function isDatabaseEmpty() {
|
||||
const fieldsCount = await prisma.field.count()
|
||||
return fieldsCount === 0
|
||||
}
|
||||
|
||||
async function main() {
|
||||
// Clean up existing data
|
||||
// await prisma.category.deleteMany({})
|
||||
// await prisma.currency.deleteMany({})
|
||||
// await prisma.field.deleteMany({})
|
||||
// await prisma.setting.deleteMany({})
|
||||
// await prisma.project.deleteMany({})
|
||||
const isEmpty = await isDatabaseEmpty()
|
||||
if (!isEmpty && !forceSeed) {
|
||||
console.log("Database is already seeded. Use 'npm run seed -- --force' to force reseeding.")
|
||||
return
|
||||
}
|
||||
|
||||
console.log("Starting database seeding...")
|
||||
|
||||
// Seed projects
|
||||
for (const project of projects) {
|
||||
|
||||
Reference in New Issue
Block a user