Compare commits
1 Commits
master
...
devcontain
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3231a27e59 |
43
.devcontainer/devcontainer.json
Normal file
43
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,43 @@
|
||||
// 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": [
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
// Forwards ports
|
||||
"forwardPorts": [
|
||||
8080
|
||||
],
|
||||
"portsAttributes": {
|
||||
"8080": {
|
||||
"label": "Adminer",
|
||||
"onAutoForward": "notify"
|
||||
}
|
||||
},
|
||||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
"postCreateCommand": [
|
||||
"bash .devcontainer/scripts/postCreateCommand.sh"
|
||||
],
|
||||
|
||||
// Container Env
|
||||
"containerEnv": {
|
||||
"MYSQL_HOST": "mysql",
|
||||
"MYSQL_USER": "root",
|
||||
"MYSQL_PASSWORD": "root"
|
||||
},
|
||||
|
||||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||
"remoteUser": "node"
|
||||
}
|
||||
4
.devcontainer/scripts/postCreateCommand.sh
Executable file
4
.devcontainer/scripts/postCreateCommand.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
pnpm i
|
||||
socat TCP4-LISTEN:8080,reuseaddr,fork TCP:adminer:8080 &
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,6 +8,7 @@ lerna-debug.log*
|
||||
|
||||
.npmrc
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
|
||||
config/config.prod.ts
|
||||
config/**/*.js
|
||||
|
||||
@@ -6,7 +6,12 @@ WORKDIR /usr/src/app
|
||||
# Install app dependencies
|
||||
COPY . .
|
||||
|
||||
RUN npm install -g npminstall --registry=https://registry.npmmirror.com \
|
||||
# NPM Mirror
|
||||
# npm install -g npminstall --registry=https://registry.npmmirror.com
|
||||
# apk add --no-cache socat \
|
||||
RUN apt-get update \
|
||||
&& apt-get -y install socat \
|
||||
&& npm install -g npminstall \
|
||||
&& npminstall -c \
|
||||
&& npm run tsc
|
||||
|
||||
|
||||
@@ -1,5 +1,30 @@
|
||||
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
|
||||
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 +32,7 @@ services:
|
||||
volumes:
|
||||
- cnpm-redis:/data
|
||||
ports:
|
||||
- 6379:6379
|
||||
- 6379
|
||||
networks:
|
||||
- cnpm
|
||||
|
||||
@@ -16,7 +41,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
|
||||
@@ -25,33 +50,30 @@ services:
|
||||
- cnpm-mysql:/var/lib/mysql
|
||||
# - ./conf.d/mysql/:/etc/mysql/conf.d
|
||||
# - ./init.d/mysql/:/docker-entrypoint-initdb.d
|
||||
- ./sql:/docker-entrypoint-initdb.d/sql
|
||||
- ./prepare-database.sh:/docker-entrypoint-initdb.d/init.sh
|
||||
ports:
|
||||
- 3306:3306
|
||||
- 3306
|
||||
networks:
|
||||
- cnpm
|
||||
|
||||
# database explorer
|
||||
phpmyadmin:
|
||||
image: phpmyadmin
|
||||
adminer:
|
||||
image: adminer
|
||||
restart: always
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD:
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
|
||||
MYSQL_USER: user
|
||||
MYSQL_PASSWORD: pass
|
||||
PMA_HOST: 'mysql'
|
||||
ports:
|
||||
- 8080:80
|
||||
networks:
|
||||
- cnpm
|
||||
ADMINER_DEFAULT_DB_HOST: 'mysql'
|
||||
depends_on:
|
||||
- mysql
|
||||
ports:
|
||||
- 8080
|
||||
networks:
|
||||
- cnpm
|
||||
|
||||
volumes:
|
||||
cnpm-redis:
|
||||
cnpm-mysql:
|
||||
|
||||
|
||||
networks:
|
||||
cnpm:
|
||||
name: cnpm
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user