working devcontainer

This commit is contained in:
2020-10-16 07:43:11 +00:00
committed by Stepan Usatiuk
parent 20865da8b9
commit 8bd57fcf9e
6 changed files with 65 additions and 12 deletions

View File

@@ -2,14 +2,16 @@
ARG VARIANT="14-buster" ARG VARIANT="14-buster"
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT} FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}
ENV DOCKERDEV=true
# Update args in docker-compose.yaml to set the UID/GID of the "node" user. # Update args in docker-compose.yaml to set the UID/GID of the "node" user.
ARG USER_UID=1000 ARG USER_UID=1000
ARG USER_GID=$USER_UID ARG USER_GID=$USER_UID
RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \ RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
groupmod --gid $USER_GID node \ groupmod --gid $USER_GID node \
&& usermod --uid $USER_UID --gid $USER_GID node \ && usermod --uid $USER_UID --gid $USER_GID node \
&& chmod -R $USER_UID:$USER_GID /home/node \ && chmod -R $USER_UID:$USER_GID /home/node \
&& chmod -R $USER_UID:root /usr/local/share/nvm /usr/local/share/npm-global; \ && chmod -R $USER_UID:root /usr/local/share/nvm /usr/local/share/npm-global; \
fi fi
RUN sudo -u node npm config set unsafe-perm=true RUN sudo -u node npm config set unsafe-perm=true

View File

@@ -39,7 +39,8 @@
"dbaeumer.vscode-eslint", "dbaeumer.vscode-eslint",
"mtxr.sqltools", "mtxr.sqltools",
"mtxr.sqltools-driver-mysql", "mtxr.sqltools-driver-mysql",
"ms-vscode.vscode-typescript-tslint-plugin" "visualstudioexptteam.vscodeintellicode",
"rvest.vs-code-prettier-eslint",
], ],
// Use 'forwardPorts' to make a list of ports inside the container available locally. // Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [ "forwardPorts": [
@@ -49,5 +50,5 @@
// Use 'postCreateCommand' to run commands after the container is created. // Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm config set unsafe-perm=true && npm i && cd frontend && npm i", "postCreateCommand": "npm config set unsafe-perm=true && npm i && cd frontend && npm i",
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "node" "remoteUser": "node"
} }

View File

@@ -22,7 +22,7 @@ services:
network_mode: service:db network_mode: service:db
# Uncomment the next line to use a non-root user for all processes. # Uncomment the next line to use a non-root user for all processes.
# user: node user: node
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally. # Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.) # (Adding the "ports" property to this file will not forward from a Codespace.)
@@ -31,7 +31,7 @@ services:
image: mariadb:latest image: mariadb:latest
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- mariadb-data:/var/lib/mysql - photosmariadb-data:/var/lib/mysql
environment: environment:
MYSQL_DATABASE: photos MYSQL_DATABASE: photos
MYSQL_USER: photos MYSQL_USER: photos
@@ -42,7 +42,7 @@ services:
image: mariadb:latest image: mariadb:latest
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- mariadbtest-data:/var/lib/mysql - photosmariadbtest-data:/var/lib/mysql
environment: environment:
MYSQL_DATABASE: photos_test MYSQL_DATABASE: photos_test
MYSQL_USER: photos MYSQL_USER: photos
@@ -53,5 +53,5 @@ services:
# (Adding the "ports" property to this file will not forward from a Codespace.) # (Adding the "ports" property to this file will not forward from a Codespace.)
volumes: volumes:
mariadb-data: photosmariadb-data:
mariadbtest-data: photosmariadbtest-data:

View File

@@ -0,0 +1,25 @@
{
"type": "mariadb",
"host": "db",
"port": 3306,
"username": "photos",
"password": "photos",
"database": "photos",
"synchronize": true,
"logging": false,
"entities": [
"src/entity/**/*.ts"
],
"migrations": [
"src/migration/**/*.ts"
],
"subscribers": [
"src/subscriber/**/*.ts"
],
"cli": {
"entitiesDir": "src/entity",
"migrationsDir": "src/migration",
"subscribersDir": "src/subscriber"
},
"charset": "utf8mb4"
}

View File

@@ -0,0 +1,25 @@
{
"type": "mariadb",
"host": "dbtest",
"port": 3306,
"username": "photos",
"password": "photos",
"database": "photos_test",
"synchronize": true,
"logging": false,
"entities": [
"src/entity/**/*.ts"
],
"migrations": [
"src/migration/**/*.ts"
],
"subscribers": [
"src/subscriber/**/*.ts"
],
"cli": {
"entitiesDir": "src/entity",
"migrationsDir": "src/migration",
"subscribersDir": "src/subscriber"
},
"charset": "utf8mb4"
}

View File

@@ -78,7 +78,7 @@ export class User extends BaseEntity {
@AfterInsert() @AfterInsert()
async createDataDir(): Promise<void> { async createDataDir(): Promise<void> {
await fs.mkdir(this.getDataPath()); await fs.mkdir(this.getDataPath(), { recursive: true });
} }
@BeforeRemove() @BeforeRemove()