hopefully working dev container

This commit is contained in:
2020-10-04 11:12:58 +03:00
parent d060194046
commit eafd8ee16d
6 changed files with 173 additions and 1 deletions

27
.devcontainer/Dockerfile Normal file
View File

@@ -0,0 +1,27 @@
# Update the VARIANT arg in docker-compose.yml to pick a Node version: 10, 12, 14
ARG VARIANT="14-buster"
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}
# Update args in docker-compose.yaml to set the UID/GID of the "node" user.
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
groupmod --gid $USER_GID node \
&& usermod --uid $USER_UID --gid $USER_GID node \
&& chmod -R $USER_UID:$USER_GID /home/node \
&& chmod -R $USER_UID:root /usr/local/share/nvm /usr/local/share/npm-global; \
fi
RUN sudo -u node npm config set unsafe-perm=true
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# [Optional] Uncomment if you want to install an additional version of node using nvm
# ARG EXTRA_NODE_VERSION=10
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
# [Optional] Uncomment if you want to install more global node packages
# RUN sudo -u node npm install -g <your-package-list-here>

View File

@@ -0,0 +1,39 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/javascript-node-postgres
// Update the VARIANT arg in docker-compose.yml to pick a Node.js version: 10, 12, 14
{
"name": "DevEnv",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"sqltools.connections": [
{
"name": "MySQL",
"server": "localhost",
"driver": "MySQL",
"port": 3306,
"database": "writer",
"username": "writer",
"askForPassword": false,
"password": "writer",
"connectionTimeout": 15
}
]
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"dbaeumer.vscode-eslint",
"mtxr.sqltools",
"mtxr.sqltools-driver-mysql",
"ms-vscode.vscode-typescript-tslint-plugin"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [1234, 3000],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm i && cd frontend && npm i",
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "node"
}

View File

@@ -0,0 +1,57 @@
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: mariadb:latest
restart: unless-stopped
volumes:
- mariadb-data:/var/lib/mysql
environment:
MYSQL_DATABASE: writer
MYSQL_USER: writer
MYSQL_PASSWORD: writer
MYSQL_ROOT_PASSWORD: writer
dbtest:
image: mariadb:latest
restart: unless-stopped
volumes:
- mariadbtest-data:/var/lib/mysql
environment:
MYSQL_DATABASE: writer_test
MYSQL_USER: writer
MYSQL_PASSWORD: writer
MYSQL_ROOT_PASSWORD: writer
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward MongoDB locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
volumes:
mariadb-data:
mariadbtest-data:

1
.gitignore vendored
View File

@@ -5,7 +5,6 @@ tmp/
temp/
dist/
ormconfig.json
ormconfig.test.json
.env
.directory
.history

25
ormconfig.dev.json Normal file
View File

@@ -0,0 +1,25 @@
{
"type": "mariadb",
"host": "db",
"port": 3306,
"username": "writer",
"password": "writer",
"database": "writer",
"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"
}

25
ormconfig.test.json Normal file
View File

@@ -0,0 +1,25 @@
{
"type": "mariadb",
"host": "dbtest",
"port": 3306,
"username": "writer",
"password": "writer",
"database": "writer_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"
}