-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add libpq to docker image, add script and readme
- Loading branch information
Showing
8 changed files
with
213 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const SERVER_URI = process.env.REACT_APP_SERVER_URI ?? "http://localhost:8080" | ||
export const SERVER_URI = process.env.REACT_APP_SERVER_URI ?? "http://localhost:8080"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# Source environment variables | ||
source .env | ||
NETWORK_NAME="forc_pub_net" | ||
CONTAINER_NAME="forc_pub_db" | ||
|
||
# Check if Docker is installed | ||
if ! command -v docker &> /dev/null; then | ||
echo "Docker is not installed. Please install Docker to run this script." | ||
exit 1 | ||
fi | ||
|
||
# Check if the PostgreSQL container is already running | ||
if docker ps --format '{{.Names}}' | grep -q '^postgres$'; then | ||
if docker ps --format '{{.Names}}' | grep -q ^$CONTAINER_NAME$; then | ||
echo "PostgreSQL container is already running." | ||
exit 0 | ||
fi | ||
|
||
# Source environment variables | ||
source .env | ||
# Create docker network if it does not exist | ||
if [ -z $(docker network ls --filter name=^${NETWORK_NAME}$ --format="{{ .Name }}") ] ; then | ||
echo "Creating docker network ${NETWORK_NAME}." | ||
docker network create $NETWORK_NAME | ||
fi | ||
|
||
# Start PostgreSQL container | ||
docker run --name $POSTGRES_USER -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD -e POSTGRES_DB=$POSTGRES_DB_NAME -d -p $POSTGRES_PORT:$POSTGRES_PORT postgres | ||
docker run \ | ||
--rm -d \ | ||
--name $CONTAINER_NAME \ | ||
--network $NETWORK_NAME \ | ||
-e POSTGRES_PASSWORD=$POSTGRES_PASSWORD \ | ||
-e POSTGRES_DB=$POSTGRES_DB_NAME \ | ||
-p $POSTGRES_PORT:$POSTGRES_PORT \ | ||
postgres | ||
|
||
echo "PostgreSQL container started successfully." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash | ||
|
||
# Start the PostgreSQL container | ||
./scripts/start_local_db.sh | ||
|
||
# Source environment variables | ||
source .env | ||
|
||
CONTAINER_NAME="forc_pub_dev" | ||
NETWORK_NAME="forc_pub_net" | ||
DB_CONTAINER_NAME="forc_pub_db" | ||
FORCE_REBUILD=false | ||
|
||
# Check for command line arguments | ||
while getopts "f" opt; do | ||
case ${opt} in | ||
f) | ||
FORCE_REBUILD=true | ||
;; | ||
\?) | ||
echo "Usage: $0 [-f]" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Check if Docker image exists | ||
if $FORCE_REBUILD || [[ "$(docker images -q $DOCKER_IMAGE 2> /dev/null)" == "" ]]; then | ||
echo "Building Docker image $DOCKER_IMAGE..." | ||
|
||
# Build Docker image | ||
docker build -t $CONTAINER_NAME -f deployment/Dockerfile . | ||
|
||
# Check if build was successful | ||
if [ $? -eq 0 ]; then | ||
echo "Docker image $DOCKER_IMAGE built successfully." | ||
else | ||
echo "Failed to build Docker image $DOCKER_IMAGE." | ||
exit 1 | ||
fi | ||
else | ||
echo "Docker image $DOCKER_IMAGE already exists. Use -f flag to force rebuild." | ||
fi | ||
|
||
# Remove the container if it exists | ||
if [[ "$(docker ps -aqf name=$CONTAINER_NAME)" ]]; then | ||
# Stop the container if it's running | ||
if [[ "$(docker ps -q -f name=$CONTAINER_NAME)" ]]; then | ||
echo "Stopping container $CONTAINER_NAME..." | ||
docker stop $CONTAINER_NAME | ||
if [ $? -eq 0 ]; then | ||
echo "Container $CONTAINER_NAME stopped successfully." | ||
else | ||
echo "Failed to stop container $CONTAINER_NAME." | ||
exit 1 | ||
fi | ||
fi | ||
fi | ||
|
||
# Start the Docker container on the same network as the PostgreSQL container | ||
docker run \ | ||
--rm -d \ | ||
--name $CONTAINER_NAME \ | ||
--network $NETWORK_NAME \ | ||
-p 8080:8080 \ | ||
-e POSTGRES_USER=$POSTGRES_USER \ | ||
-e POSTGRES_PASSWORD=$POSTGRES_PASSWORD \ | ||
-e POSTGRES_URI=$DB_CONTAINER_NAME \ | ||
-e POSTGRES_DB_NAME=$POSTGRES_DB_NAME \ | ||
$CONTAINER_NAME | ||
|
||
echo "Server container started successfully." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters