-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from SageSeekerSociety/chore-add-docker-script
chore: add script to start docker dependencies
- Loading branch information
Showing
6 changed files
with
193 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
sudo systemctl start docker | ||
sudo docker restart elasticsearch postgres cheese_legacy |
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,63 @@ | ||
#!/bin/sh | ||
sudo systemctl start docker.service | ||
|
||
sudo docker network create cheese_network | ||
|
||
sudo docker run -d \ | ||
--name elasticsearch \ | ||
--network cheese_network \ | ||
-e discovery.type=single-node \ | ||
-e xpack.security.enabled=true \ | ||
-e ELASTIC_USERNAME=elastic \ | ||
-e ELASTIC_PASSWORD=elastic \ | ||
--health-cmd="curl http://localhost:9200/_cluster/health" \ | ||
--health-interval=10s \ | ||
--health-timeout=5s \ | ||
--health-retries=10 \ | ||
-p 9200:9200 \ | ||
docker.elastic.co/elasticsearch/elasticsearch:8.12.1 | ||
|
||
sudo docker run -d \ | ||
--name postgres \ | ||
--network cheese_network \ | ||
-e POSTGRES_PASSWORD=postgres \ | ||
--health-cmd="pg_isready" \ | ||
--health-interval=10s \ | ||
--health-timeout=5s \ | ||
--health-retries=5 \ | ||
-p 5432:5432 \ | ||
postgres | ||
echo "Wait for 5 seconds please..." | ||
sleep 5 | ||
sudo docker exec -i postgres bash << EOF | ||
sed -i -e 's/max_connections = 100/max_connections = 1000/' /var/lib/postgresql/data/postgresql.conf | ||
sed -i -e 's/shared_buffers = 128MB/shared_buffers = 2GB/' /var/lib/postgresql/data/postgresql.conf | ||
EOF | ||
sudo docker restart --time 0 postgres | ||
|
||
sudo docker run -d \ | ||
--name cheese_legacy \ | ||
--network cheese_network \ | ||
-p 3000:3000 \ | ||
-e PORT=3000 \ | ||
-e JWT_SECRET="test-secret" \ | ||
-e PRISMA_DATABASE_URL="postgresql://postgres:postgres@postgres:5432/postgres?schema=public&connection_limit=16" \ | ||
-e ELASTICSEARCH_NODE=http://elasticsearch:9200/ \ | ||
-e ELASTICSEARCH_AUTH_USERNAME=elastic \ | ||
-e ELASTICSEARCH_AUTH_PASSWORD=elastic \ | ||
-e FILE_UPLOAD_PATH=/app/uploads \ | ||
-e DEFAULT_AVATAR_NAME=default.jpg \ | ||
-e EMAIL_SMTP_HOST=smtp.example.com \ | ||
-e EMAIL_SMTP_PORT=587 \ | ||
-e EMAIL_SMTP_SSL_ENABLE=true \ | ||
-e EMAIL_SMTP_USERNAME=user@example.com \ | ||
-e EMAIL_SMTP_PASSWORD=a_super_strong_password \ | ||
-e EMAIL_DEFAULT_FROM="No Reply <noreply@example.com>" \ | ||
ghcr.io/sageseekersociety/cheese-backend-dev:dev \ | ||
bash -c ' | ||
if [ ! -f "FLAG_INIT" ]; then | ||
touch FLAG_INIT | ||
pnpm prisma db push | ||
fi | ||
pnpm start | ||
' |
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,3 @@ | ||
#!/bin/sh | ||
sudo systemctl start docker | ||
sudo docker restart elasticsearch postgres |
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,32 @@ | ||
#!/bin/sh | ||
sudo systemctl start docker.service | ||
|
||
sudo docker run -d \ | ||
--name elasticsearch \ | ||
-e discovery.type=single-node \ | ||
-e xpack.security.enabled=true \ | ||
-e ELASTIC_USERNAME=elastic \ | ||
-e ELASTIC_PASSWORD=elastic \ | ||
--health-cmd="curl http://localhost:9200/_cluster/health" \ | ||
--health-interval=10s \ | ||
--health-timeout=5s \ | ||
--health-retries=10 \ | ||
-p 9200:9200 \ | ||
docker.elastic.co/elasticsearch/elasticsearch:8.12.1 | ||
|
||
sudo docker run -d \ | ||
--name postgres \ | ||
-e POSTGRES_PASSWORD=postgres \ | ||
--health-cmd="pg_isready" \ | ||
--health-interval=10s \ | ||
--health-timeout=5s \ | ||
--health-retries=5 \ | ||
-p 5432:5432 \ | ||
postgres | ||
echo "Wait for 5 seconds please..." | ||
sleep 5 | ||
sudo docker exec -i postgres bash << EOF | ||
sed -i -e 's/max_connections = 100/max_connections = 1000/' /var/lib/postgresql/data/postgresql.conf | ||
sed -i -e 's/shared_buffers = 128MB/shared_buffers = 2GB/' /var/lib/postgresql/data/postgresql.conf | ||
EOF | ||
sudo docker restart --time 0 postgres |
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,63 @@ | ||
# The port that the app will listen to | ||
PORT=3000 | ||
|
||
# The secret used to sign the JWT token | ||
# You MUST change this secret to your own secret! | ||
# Otherwise, your app will be as insecure as with an empty admin password! | ||
JWT_SECRET="test-secret" | ||
|
||
DB_HOST=localhost # set DB_HOST to database to use with docker | ||
DB_USERNAME=postgres | ||
DB_PASSWORD=postgres # your passowrd | ||
DB_PASSWORD_URL_FORMAT=postgres # password in url-format, see https://github.com/prisma/prisma/discussions/15679 | ||
DB_PORT=5432 | ||
DB_NAME=postgres | ||
|
||
# The connection URL of the database for Prisma | ||
# See https://www.prisma.io/docs/orm/reference/connection-urls for more information | ||
# Keep align with the TypeORM configuration | ||
PRISMA_DATABASE_URL="postgresql://${DB_USERNAME}:${DB_PASSWORD_URL_FORMAT}@${DB_HOST}:${DB_PORT}/${DB_NAME}?schema=public&connection_limit=16" | ||
|
||
# The maximum amount of time the interactive transaction can run before being canceled and rolled back. | ||
# See: https://github.com/prisma/prisma/releases/tag/5.10.0 | ||
# See: https://github.com/prisma/prisma/issues/15028 | ||
PRISMA_TRANSACTION_TIMEOUT=60000 # 60s | ||
|
||
# The configuration for Elasticsearch | ||
ELASTICSEARCH_NODE=http://localhost:9200/ | ||
ELASTICSEARCH_MAX_RETRIES=10 | ||
ELASTICSEARCH_REQUEST_TIMEOUT=60000 | ||
ELASTICSEARCH_PING_TIMEOUT=60000 | ||
ELASTICSEARCH_SNIFF_ON_START=true | ||
ELASTICSEARCH_AUTH_USERNAME=elastic | ||
ELASTICSEARCH_AUTH_PASSWORD=elastic | ||
|
||
# The configuration for uploaded files | ||
FILE_UPLOAD_PATH=/tmp/app/uploads | ||
DEFAULT_AVATAR_NAME=default.jpg | ||
|
||
|
||
# The configuration for CORS | ||
CORS_ORIGINS=http://localhost:3000 # use `,` to separate multiple origins | ||
CORS_METHODS=GET,POST,PUT,PATCH,DELETE | ||
CORS_HEADERS=Content-Type,Authorization | ||
CORS_CREDENTIALS=true | ||
|
||
# additionally setup the following if you want to use docker-compose | ||
# to setup environment | ||
POSTGRES_DB=${DB_NAME} | ||
POSTGRES_USER=${DB_USERNAME} | ||
POSTGRES_PASSWORD=${DB_PASSWORD} | ||
|
||
# Email configuration: | ||
EMAIL_SMTP_HOST=smtp.example.com | ||
EMAIL_SMTP_PORT=587 | ||
EMAIL_SMTP_SSL_ENABLE=true | ||
EMAIL_SMTP_USERNAME=user@example.com | ||
EMAIL_SMTP_PASSWORD=a_super_strong_password | ||
EMAIL_DEFAULT_FROM='"No Reply" <noreply@example.com>' | ||
|
||
# Email test configuration: | ||
# Enabling email test means when you run test, emails will be sent. | ||
EMAILTEST_ENABLE=false | ||
EMAILTEST_RECEIVER=developer@example.com |