This is a web application created for our DevOps workshop. Its primary purpose is to demonstrate server automation.
-
Clone the repository and navigate to its directory:
$ git clone https://github.com/ilmossp/webapp-devops $ cd webapp-devops
-
Create a
.env
file:$ touch .env
-
Add the database connection URL to the
.env
file. Depending on your database choice, use one of the following examples:-
For SQLite:
# SQLite DB_CONNECTION_STRING="sqlite:/path/to/file.db"
-
For PostgreSQL:
# PostgreSQL DB_CONNECTION_STRING="postgres://user:[email protected]:5432/dbname"
-
-
Install the required dependencies:
npm install
-
Start the application:
node app.js
-
The application should now be listening on port 3000.
-
On your first run, make sure to send a request to the API route
/sync
in order to create the necessary database tables.
Assuming you have cloned the project and are running it from the project directory:
-
Build the Docker image:
docker build -t webapp .
-
Run the Docker container, mapping port 4000 on your host machine to port 3000 in the container, and provide the
DB_CONNECTION_STRING
as an environment variable (replaceYOURCONNECTIONSTRING
with your actual database connection string):docker run -p 4000:3000 -e DB_CONNECTION_STRING=YOURCONNECTIONSTRING webapp