diff --git a/Dockerfile b/Dockerfile index 97eb7d7..a9d97fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ FROM node:18-alpine AS external-website # A small line inside the image to show who made it LABEL Developers="Sean Morley" +RUN apk update && apk add postgresql-client + # The WORKDIR instruction sets the working directory for everything that will happen next WORKDIR /app diff --git a/docker-compose.yml b/docker-compose.yml index a050d04..4a58128 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: web: - image: ghcr.io/seanmorley15/adventurelog:latest + build: . ports: - "3000:3000" environment: @@ -9,6 +9,8 @@ services: - ORIGIN=http://localhost:3000 depends_on: - db + volumes: + - ./sql:/sql db: image: postgres environment: diff --git a/sampleData/parks.sql b/sql/parks.sql similarity index 100% rename from sampleData/parks.sql rename to sql/parks.sql diff --git a/startup.sh b/startup.sh index 07e73f8..10039d0 100644 --- a/startup.sh +++ b/startup.sh @@ -9,8 +9,22 @@ wait_for_db() { echo "Database is now available." } +# Function to run SQL scripts +run_sql_scripts() { + echo "Running SQL scripts..." + + # Define the path to your SQL scripts + SQL_SCRIPTS_PATH="/sql" # Replace with the path to your SQL scripts + + # Run each SQL script in the directory using the DATABASE_URL + for sql_script in "$SQL_SCRIPTS_PATH"/*.sql; do + echo "Running script: $sql_script" + psql "$DATABASE_URL" -f "$sql_script" + done + echo "Finished running SQL scripts." +} + # Start your application here -# Example: node build/index.js # Print message echo "Starting AdventureLog" @@ -23,6 +37,9 @@ npm run generate # Run database migration npm run migrate -echo "The orgin to be set is: $ORIGIN" +# Run SQL scripts +run_sql_scripts + +echo "The origin to be set is: $ORIGIN" # Start the application ORIGIN=$ORIGIN node build