mirror of
https://github.com/usatiuk/photos.git
synced 2025-10-28 15:27:49 +01:00
Compare commits
2 Commits
b9149464f7
...
09844e5294
| Author | SHA1 | Date | |
|---|---|---|---|
| 09844e5294 | |||
| 101e2ceed7 |
@@ -1,20 +1,5 @@
|
|||||||
# Update the VARIANT arg in docker-compose.yml to pick a Node version: 10, 12, 14
|
ARG VARIANT=16-bullseye
|
||||||
ARG VARIANT="16-buster"
|
FROM mcr.microsoft.com/vscode/devcontainers/javascript-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.
|
|
||||||
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.
|
# [Optional] Uncomment this section to install additional OS packages.
|
||||||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||||
@@ -24,6 +9,5 @@ RUN sudo -u node npm config set unsafe-perm=true
|
|||||||
# ARG EXTRA_NODE_VERSION=10
|
# ARG EXTRA_NODE_VERSION=10
|
||||||
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
|
# 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
|
# [Optional] Uncomment if you want to install more global node modules
|
||||||
# RUN sudo -u node npm install -g <your-package-list-here>
|
# RUN su node -c "npm install -g <your-package-list-here>"
|
||||||
|
|
||||||
5
.devcontainer/dbinit/fix.sql
Executable file
5
.devcontainer/dbinit/fix.sql
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
FLUSH PRIVILEGES ;
|
||||||
|
DROP USER ''@'localhost' ;
|
||||||
|
create database if not exists `photostestdb` ;
|
||||||
|
grant all privileges on `photostestdb`.* to 'photostestuser'@'%' identified by 'photostestpass' ;
|
||||||
|
FLUSH PRIVILEGES ;
|
||||||
@@ -9,12 +9,18 @@
|
|||||||
// Set *default* container specific settings.json values on container create.
|
// Set *default* container specific settings.json values on container create.
|
||||||
"settings": {},
|
"settings": {},
|
||||||
// Add the IDs of extensions you want installed when the container is created.
|
// Add the IDs of extensions you want installed when the container is created.
|
||||||
"extensions": ["dbaeumer.vscode-eslint"],
|
"extensions": [
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"mikestead.dotenv",
|
||||||
|
"esbenp.prettier-vscode",
|
||||||
|
"foxundermoon.shell-format",
|
||||||
|
"ms-azuretools.vscode-docker"
|
||||||
|
],
|
||||||
// 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": [1234, 3000],
|
"forwardPorts": [1234, 3000],
|
||||||
// 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",
|
||||||
"postCreateCommand": "cd /workspace; if [ ! -f ormconfig.json ]; then cp ormconfig.dockerdevexample.json ormconfig.json; fi; if [ ! -f ormconfig.test.json ]; then cp ormconfig.dockerdevexample.test.json ormconfig.test.json; fi;"
|
"postCreateCommand": "cd /workspace; if [ ! -f ormconfig.json ]; then cp ormconfig.dockerdevexample.json ormconfig.json; fi; if [ ! -f ormconfig.test.json ]; then cp ormconfig.dockerdevexample.test.json ormconfig.test.json; fi; npm i && cd frontend && npm i"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,54 +2,33 @@ version: '3'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
args:
|
|
||||||
# [Choice] Node.js version: 14, 12, 10
|
|
||||||
VARIANT: 16
|
|
||||||
# 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:
|
volumes:
|
||||||
- ..:/workspace:cached
|
- ..:/workspace:cached
|
||||||
|
|
||||||
# Overrides default command so things don't shut down after the process ends.
|
# Overrides default command so things don't shut down after the process ends.
|
||||||
command: sleep infinity
|
command: sleep infinity
|
||||||
|
|
||||||
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
|
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
|
||||||
network_mode: service:db
|
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:
|
db:
|
||||||
image: mariadb:latest
|
image: yobasystems/alpine-mariadb:10.6
|
||||||
volumes:
|
volumes:
|
||||||
- photosmariadb-data:/var/lib/mysql
|
- photosmariadb-data:/var/lib/mysql
|
||||||
|
- ./dbinit:/docker-entrypoint-initdb.d:ro
|
||||||
environment:
|
environment:
|
||||||
MYSQL_DATABASE: photos
|
MYSQL_DATABASE: photosdb
|
||||||
MYSQL_USER: photos
|
MYSQL_USER: photosuser
|
||||||
MYSQL_PASSWORD: photos
|
MYSQL_PASSWORD: photospass
|
||||||
MYSQL_ROOT_PASSWORD: photos
|
MYSQL_ROOT_PASSWORD: photosroot
|
||||||
|
healthcheck:
|
||||||
dbtest:
|
test: "mysql $$MYSQL_DATABASE -u$$MYSQL_USER -p$$MYSQL_PASSWORD -e 'SELECT 1;'"
|
||||||
image: mariadb:latest
|
interval: 10s
|
||||||
volumes:
|
timeout: 10s
|
||||||
- photosmariadbtest-data:/var/lib/mysql
|
retries: 10
|
||||||
environment:
|
|
||||||
MYSQL_DATABASE: photos_test
|
|
||||||
MYSQL_USER: photos
|
|
||||||
MYSQL_PASSWORD: photos
|
|
||||||
MYSQL_ROOT_PASSWORD: photos
|
|
||||||
|
|
||||||
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward MongoDB locally.
|
|
||||||
# (Adding the "ports" property to this file will not forward from a Codespace.)
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
photosmariadb-data:
|
photosmariadb-data:
|
||||||
photosmariadbtest-data:
|
|
||||||
6
mocha.json
Executable file
6
mocha.json
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"reporterEnabled": "spec, mocha-junit-reporter",
|
||||||
|
"mochaJunitReporterReporterOptions": {
|
||||||
|
"mochaFile":"backend-report.xml"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,24 +2,18 @@
|
|||||||
"type": "mariadb",
|
"type": "mariadb",
|
||||||
"host": "db",
|
"host": "db",
|
||||||
"port": 3306,
|
"port": 3306,
|
||||||
"username": "photos",
|
"username": "photosuser",
|
||||||
"password": "photos",
|
"password": "photospass",
|
||||||
"database": "photos",
|
"database": "photosdb",
|
||||||
"synchronize": false,
|
"synchronize": false,
|
||||||
"logging": false,
|
"logging": false,
|
||||||
"entities": [
|
"entities": ["src/entity/**/*.ts"],
|
||||||
"src/entity/**/*.ts"
|
"migrations": ["src/migration/**/*.ts"],
|
||||||
],
|
"subscribers": ["src/subscriber/**/*.ts"],
|
||||||
"migrations": [
|
|
||||||
"src/migration/**/*.ts"
|
|
||||||
],
|
|
||||||
"subscribers": [
|
|
||||||
"src/subscriber/**/*.ts"
|
|
||||||
],
|
|
||||||
"cli": {
|
"cli": {
|
||||||
"entitiesDir": "src/entity",
|
"entitiesDir": "src/entity",
|
||||||
"migrationsDir": "src/migration",
|
"migrationsDir": "src/migration",
|
||||||
"subscribersDir": "src/subscriber"
|
"subscribersDir": "src/subscriber"
|
||||||
},
|
},
|
||||||
"charset": "utf8mb4"
|
"charset": "utf8mb4"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,19 @@
|
|||||||
{
|
{
|
||||||
"type": "mariadb",
|
"type": "mariadb",
|
||||||
"host": "dbtest",
|
"host": "db",
|
||||||
"port": 3306,
|
"port": 3306,
|
||||||
"username": "photos",
|
"username": "photostestuser",
|
||||||
"password": "photos",
|
"password": "photostestpass",
|
||||||
"database": "photos_test",
|
"database": "photostestdb",
|
||||||
"synchronize": true,
|
"synchronize": true,
|
||||||
"logging": false,
|
"logging": false,
|
||||||
"entities": [
|
"entities": ["src/entity/**/*.ts"],
|
||||||
"src/entity/**/*.ts"
|
"migrations": ["src/migration/**/*.ts"],
|
||||||
],
|
"subscribers": ["src/subscriber/**/*.ts"],
|
||||||
"migrations": [
|
|
||||||
"src/migration/**/*.ts"
|
|
||||||
],
|
|
||||||
"subscribers": [
|
|
||||||
"src/subscriber/**/*.ts"
|
|
||||||
],
|
|
||||||
"cli": {
|
"cli": {
|
||||||
"entitiesDir": "src/entity",
|
"entitiesDir": "src/entity",
|
||||||
"migrationsDir": "src/migration",
|
"migrationsDir": "src/migration",
|
||||||
"subscribersDir": "src/subscriber"
|
"subscribersDir": "src/subscriber"
|
||||||
},
|
},
|
||||||
"charset": "utf8mb4"
|
"charset": "utf8mb4"
|
||||||
}
|
}
|
||||||
|
|||||||
29
package-lock.json
generated
Normal file → Executable file
29
package-lock.json
generated
Normal file → Executable file
@@ -70,7 +70,8 @@
|
|||||||
"@types/prettier": "^2.7.2",
|
"@types/prettier": "^2.7.2",
|
||||||
"@types/sharp": "^0.31.1",
|
"@types/sharp": "^0.31.1",
|
||||||
"@types/supertest": "^2.0.12",
|
"@types/supertest": "^2.0.12",
|
||||||
"mocha-junit-reporter": "^2.2.0"
|
"mocha-junit-reporter": "^2.2.0",
|
||||||
|
"mocha-multi-reporters": "^1.5.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@cspotcode/source-map-support": {
|
"node_modules/@cspotcode/source-map-support": {
|
||||||
@@ -4322,6 +4323,22 @@
|
|||||||
"mocha": ">=2.2.5"
|
"mocha": ">=2.2.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/mocha-multi-reporters": {
|
||||||
|
"version": "1.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/mocha-multi-reporters/-/mocha-multi-reporters-1.5.1.tgz",
|
||||||
|
"integrity": "sha512-Yb4QJOaGLIcmB0VY7Wif5AjvLMUFAdV57D2TWEva1Y0kU/3LjKpeRVmlMIfuO1SVbauve459kgtIizADqxMWPg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"debug": "^4.1.1",
|
||||||
|
"lodash": "^4.17.15"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"mocha": ">=3.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/mocha/node_modules/brace-expansion": {
|
"node_modules/mocha/node_modules/brace-expansion": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
||||||
@@ -9686,6 +9703,16 @@
|
|||||||
"xml": "^1.0.1"
|
"xml": "^1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"mocha-multi-reporters": {
|
||||||
|
"version": "1.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/mocha-multi-reporters/-/mocha-multi-reporters-1.5.1.tgz",
|
||||||
|
"integrity": "sha512-Yb4QJOaGLIcmB0VY7Wif5AjvLMUFAdV57D2TWEva1Y0kU/3LjKpeRVmlMIfuO1SVbauve459kgtIizADqxMWPg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"debug": "^4.1.1",
|
||||||
|
"lodash": "^4.17.15"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ms": {
|
"ms": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
|
|||||||
5
package.json
Normal file → Executable file
5
package.json
Normal file → Executable file
@@ -6,7 +6,7 @@
|
|||||||
"start": "ts-node -T -r tsconfig-paths/register src/server.ts",
|
"start": "ts-node -T -r tsconfig-paths/register src/server.ts",
|
||||||
"ts-node-dev": "ts-node-dev -r tsconfig-paths/register ./src/server.ts",
|
"ts-node-dev": "ts-node-dev -r tsconfig-paths/register ./src/server.ts",
|
||||||
"dev": "cross-env NODE_ENV=development concurrently npm:ts-node-dev npm:start-frontend -c 'blue,green'",
|
"dev": "cross-env NODE_ENV=development concurrently npm:ts-node-dev npm:start-frontend -c 'blue,green'",
|
||||||
"test": "cross-env NODE_ENV=test mocha --timeout 15000 -r ts-node/register -r tsconfig-paths/register --reporter mocha-junit-reporter --reporter-options mochaFile=backend-report.xml 'src/tests/**/*.ts' ",
|
"test": "cross-env NODE_ENV=test mocha --timeout 15000 -r ts-node/register -r tsconfig-paths/register --reporter mocha-multi-reporters --reporter-options configFile=mocha.json 'src/tests/**/*.ts' ",
|
||||||
"test-frontend": "cd frontend && npm test",
|
"test-frontend": "cd frontend && npm test",
|
||||||
"test-all": "npm test && npm run test-frontend",
|
"test-all": "npm test && npm run test-frontend",
|
||||||
"lint": "eslint ./src/** --ext .js,.jsx,.ts,.tsx && tsc --noEmit",
|
"lint": "eslint ./src/** --ext .js,.jsx,.ts,.tsx && tsc --noEmit",
|
||||||
@@ -83,7 +83,8 @@
|
|||||||
"@types/prettier": "^2.7.2",
|
"@types/prettier": "^2.7.2",
|
||||||
"@types/sharp": "^0.31.1",
|
"@types/sharp": "^0.31.1",
|
||||||
"@types/supertest": "^2.0.12",
|
"@types/supertest": "^2.0.12",
|
||||||
"mocha-junit-reporter": "^2.2.0"
|
"mocha-junit-reporter": "^2.2.0",
|
||||||
|
"mocha-multi-reporters": "^1.5.1"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
|
|||||||
Reference in New Issue
Block a user