-
Notifications
You must be signed in to change notification settings - Fork 50
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 #332 from hngprojects/feature/docker-successful-bu…
…ilds chore: setup successful docker builds
- Loading branch information
Showing
10 changed files
with
95 additions
and
58 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
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
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,34 +1,38 @@ | ||
name: golang | ||
name: golang_dev | ||
|
||
services: | ||
db: | ||
image: postgres:16 | ||
env_file: | ||
- ./app.env | ||
- app.env | ||
volumes: | ||
- db_data:/var/lib/postgresql/data | ||
- ../pgsql_volumes/golang_dev/:/var/lib/postgresql/data | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U development_user"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 2 | ||
|
||
redis: | ||
image: redis:latest | ||
|
||
backend: | ||
image: golang_backend | ||
image: golang_dev | ||
build: | ||
context: . | ||
depends_on: | ||
- db | ||
- redis | ||
db: | ||
condition: service_healthy | ||
redis: | ||
condition: service_started | ||
env_file: | ||
- ./app.env | ||
- app.env | ||
|
||
nginx: | ||
image: nginx:latest | ||
ports: | ||
- "7000:80" | ||
depends_on: | ||
- backend | ||
ports: | ||
- "7000:80" | ||
volumes: | ||
- ./nginx.conf:/etc/nginx/nginx.conf | ||
|
||
volumes: | ||
db_data: |
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,41 @@ | ||
#!/bin/bash | ||
|
||
if [ "$#" -lt 2 ]; then | ||
echo "Description: creates new environment variables from existing ones" | ||
echo "Usage: $0 .env_file NEW_ENV1=EXISTING_ENV1 [NEW_ENV2=EXISTING_ENV2 ...]" | ||
exit 1 | ||
fi | ||
|
||
env_file="$1" | ||
shift | ||
|
||
if [ ! -f "$env_file" ]; then | ||
echo "Error: .env file '$env_file' not found." | ||
exit 1 | ||
fi | ||
|
||
export $(grep -v '^#' "$env_file" | xargs) | ||
|
||
for arg in "$@"; do | ||
IFS='=' read -r new_env existing_env <<< "$arg" | ||
|
||
if [ -z "${!existing_env}" ]; then | ||
echo "Warning: Existing environment variable '$existing_env' is not set." | ||
continue | ||
fi | ||
|
||
# Get the value of the existing environment variable | ||
value="${!existing_env}" | ||
|
||
# Export the new environment variable with the value of the existing one | ||
export "$new_env=$value" | ||
done | ||
|
||
# Write the new environment variables to the .env file | ||
{ | ||
echo | ||
for arg in "$@"; do | ||
IFS='=' read -r new_env _ <<< "$arg" | ||
echo "$new_env=${!new_env}" | ||
done | ||
} >> "$env_file" |