-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved devcontainer & created auto import for the database export
Signed-off-by: JL102 <[email protected]>
- Loading branch information
Showing
5 changed files
with
75 additions
and
54 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 |
---|---|---|
@@ -1,45 +1,45 @@ | ||
version: '3.8' | ||
|
||
services: | ||
app: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
# Update 'VARIANT' to pick an LTS version of Node.js: 18, 16, 14. | ||
# Append -bullseye or -buster to pin to an OS version. | ||
# Use -bullseye variants on local arm64/Apple Silicon. | ||
VARIANT: 18-buster | ||
volumes: | ||
- ..:/workspace:cached | ||
|
||
# Overrides default command so things don't shut down after the process ends. | ||
command: sleep infinity | ||
|
||
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. | ||
network_mode: service:db | ||
|
||
# Uncomment the next line to use a non-root user for all processes. | ||
# user: node | ||
|
||
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally. | ||
# (Adding the "ports" property to this file will not forward from a Codespace.) | ||
|
||
db: | ||
image: mongo:latest | ||
restart: unless-stopped | ||
volumes: | ||
# - mongodb-data:/data/db | ||
- /var/lib/docker/codespacemount/workspace/scoutradioz-db:/data/db | ||
|
||
# Uncomment to change startup options | ||
# environment: | ||
# MONGO_INITDB_ROOT_USERNAME: root | ||
# MONGO_INITDB_ROOT_PASSWORD: example | ||
# MONGO_INITDB_DATABASE: app | ||
|
||
# Add "forwardPorts": ["27017"] to **devcontainer.json** to forward MongoDB locally. | ||
# (Adding the "ports" property to this file will not forward from a Codespace.) | ||
|
||
# volumes: | ||
# mongodb-data: | ||
version: '3.8' | ||
|
||
services: | ||
app: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
# Update 'VARIANT' to pick an LTS version of Node.js: 18, 16, 14. | ||
# Append -bullseye or -buster to pin to an OS version. | ||
# Use -bullseye variants on local arm64/Apple Silicon. | ||
VARIANT: 18-buster | ||
volumes: | ||
- ..:/workspace:cached | ||
|
||
# Overrides default command so things don't shut down after the process ends. | ||
command: sleep infinity | ||
|
||
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. | ||
network_mode: service:db | ||
|
||
# Uncomment the next line to use a non-root user for all processes. | ||
# user: node | ||
|
||
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally. | ||
# (Adding the "ports" property to this file will not forward from a Codespace.) | ||
|
||
db: | ||
image: mongo:latest | ||
restart: unless-stopped | ||
volumes: | ||
- mongodb-data:/data/db | ||
# - /var/lib/docker/codespacemount/workspace/scoutradioz-db:/data/db | ||
|
||
# Uncomment to change startup options | ||
# environment: | ||
# MONGO_INITDB_ROOT_USERNAME: root | ||
# MONGO_INITDB_ROOT_PASSWORD: example | ||
# MONGO_INITDB_DATABASE: app | ||
|
||
# Add "forwardPorts": ["27017"] to **devcontainer.json** to forward MongoDB locally. | ||
# (Adding the "ports" property to this file will not forward from a Codespace.) | ||
|
||
volumes: | ||
mongodb-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,14 @@ | ||
#!/bin/bash | ||
|
||
# Import database | ||
echo "Unzipping database export..." | ||
mkdir -p /tmp/db-export | ||
unzip .devcontainer/db_export.zip -d /tmp/db-export/ | ||
|
||
echo "Dropping existing database..." | ||
mongosh app --eval "db.dropDatabase();" | ||
|
||
echo "Restoring database export..." | ||
mongorestore /tmp/db-export --db app | ||
|
||
rm -r /tmp/db-export |
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,5 @@ | ||
# Set core.autocrlf to true for the rest of the repository | ||
* text=auto eol=auto | ||
|
||
# Set core.autocrlf to false for the .devcontainer folder | ||
.devcontainer/* -text eol=lf |