From 8250cae054f910451b427e8088f5bc79d1c0026f Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Tue, 2 Apr 2024 14:41:07 +0000 Subject: [PATCH] Add startup script and update Dockerfile and docker-compose.yml --- Dockerfile | 9 +++++++-- docker-compose.yml | 10 ++++------ startup.sh | 8 ++++++++ 3 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 startup.sh diff --git a/Dockerfile b/Dockerfile index ca45aef..97eb7d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,8 +19,13 @@ RUN npm run build # Expose the port that the app is listening on EXPOSE 3000 + +RUN chmod +x ./startup.sh + # The USER instruction sets the user name to use as the default user for the remainder of the current stage USER node:node -# This is the command that will be run inside the image when you tell Docker to start the container -CMD ["node", "build/index.js"] +# get permission to run startup script + +# Run startup.sh instead of the default command +CMD ["./startup.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index 25036dc..297a483 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,11 +1,9 @@ +version: '3.8' + services: web: build: . ports: - "3000:3000" - # depends_on: - # - db - # db: - # image: postgres - # environment: - # POSTGRES_PASSWORD: example \ No newline at end of file + environment: + - DATABASE_URL=postgresql://seanmorley15:1XGfuKoO9wcH@ep-withered-violet-a5xm4eqj.us-east-2.aws.neon.tech/demo?sslmode=require diff --git a/startup.sh b/startup.sh new file mode 100644 index 0000000..666f95e --- /dev/null +++ b/startup.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# Start your application here +# Example: node build/index.js +# print message +echo "Starting the application" +npm run migrate +node build/index.js