Skip to main content

Posts

Showing posts from December, 2020

Visual Studio Code : .devcontainer | Dockerfile.yml (mongodb with mongo-express)

version : '3' services : app : build : context : . dockerfile : Dockerfile args : # [Choice] Node.js version: 14, 12, 10 VARIANT : 14 # On Linux, you may need to update USER_UID and USER_GID below if not your local UID is not 1000. USER_UID : 1000 USER_GID : 1000 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 :
node ➜ /workspace $ yarn init yarn init v1.22.5 question name (workspace): lotto-backend question version (1.0.0): question description: PCSO Lotto BackEnd with Express.Js & MongoDB question entry point (index.js): index.js question repository url: question author: bbytnz question license (MIT): question private: success Saved package.json Done in 330.16s. node ➜ /workspace $ npm install --save express morgan http-errors dotenv npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN lotto-backend@1.0.0 No repository field. + http-errors@1.8.0 + morgan@1.10.0 + express@4.17.1 + dotenv@8.2.0 added 61 packages from 37 contributors and audited 61 packages in 6.877s found 0 vulnerabilities node ➜ /workspace $

docker-compose : mongodb mongo-express redis rediscommander

version : "3" services : redis : image : redis:alpine container_name : redis_db command : redis-server --appendonly yes ports : - 6379:6379 volumes : - ./data:/data restart : always redis-commander : image : rediscommander/redis-commander:latest environment : - REDIS_HOSTS=local:redis:6379 ports : - 8082:8081 depends_on : - redis mongo : image : mongo restart : always ports : - "27017:27017" environment : MONGO_INITDB_ROOT_USERNAME : uroot MONGO_INITDB_ROOT_PASSWORD : usecret volumes : - ./mongo-data:/data/db mongo-express : image : mongo-express restart : always ports : - "8081:8081" environment : ME_CONFIG_MONGODB_ADMINUSERNAME : uroot ME_CONFIG_MONGODB_ADMINPASSWORD : usecret volumes : mongo-data :