diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..01b725e5 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,30 @@ +// Update the VARIANT arg in docker-compose.yml to pick a Node.js version +{ + "name": "Node.js && Redis && MySQL", + "dockerComposeFile": "../docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + ] + } + }, + + "forwardPorts": [ + "phpmyadmin:80" + ], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "pnpm i", + "containerEnv": { + "MYSQL_HOST": "mysql" + }, + + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "node" +} diff --git a/.gitignore b/.gitignore index 13fa0f64..f416fbbe 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ lerna-debug.log* .npmrc package-lock.json +pnpm-lock.yaml config/config.prod.ts config/**/*.js diff --git a/docker-compose.yml b/docker-compose.yml index 8340d2cf..6d53a325 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,34 @@ -version: '3.6' +version: '3.8' services: + app: + build: + context: . + dockerfile: Dockerfile + volumes: + - ../..:/workspaces:cached + + # Overrides default command so things don't shut down after the process ends. + command: sleep infinity + + # links: + # - redis + # - mysql + depends_on: + - mysql + - redis + networks: + - cnpm + + # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. + # networks: + # - cnpm + + # 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.) + redis: image: redis:6-alpine # command: redis-server --appendonly yes --requirepass cnpm @@ -7,7 +36,7 @@ services: volumes: - cnpm-redis:/data ports: - - 6379:6379 + - 6379 networks: - cnpm @@ -16,7 +45,7 @@ services: command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci restart: always environment: - MYSQL_ROOT_PASSWORD: + MYSQL_ROOT_PASSWORD: root MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' # MYSQL_DATABASE: 'cnpmcore_unittest' MYSQL_USER: user @@ -26,7 +55,7 @@ services: # - ./conf.d/mysql/:/etc/mysql/conf.d # - ./init.d/mysql/:/docker-entrypoint-initdb.d ports: - - 3306:3306 + - 3306 networks: - cnpm @@ -35,23 +64,22 @@ services: image: phpmyadmin restart: always environment: - MYSQL_ROOT_PASSWORD: + MYSQL_ROOT_PASSWORD: root MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' MYSQL_USER: user MYSQL_PASSWORD: pass PMA_HOST: 'mysql' + depends_on: + - mysql ports: - - 8080:80 + - 80 networks: - cnpm - depends_on: - - mysql volumes: cnpm-redis: cnpm-mysql: - networks: cnpm: name: cnpm diff --git a/test/TestUtil.ts b/test/TestUtil.ts index 1c29c5ec..cd8c2efc 100644 --- a/test/TestUtil.ts +++ b/test/TestUtil.ts @@ -49,7 +49,7 @@ export class TestUtil { host: process.env.MYSQL_HOST || '127.0.0.1', port: process.env.MYSQL_PORT || 3306, user: process.env.MYSQL_USER || 'root', - password: process.env.MYSQL_PASSWORD, + password: process.env.MYSQL_PASSWORD || '', multipleStatements: true, }; }