👷 Minimal docker compose option for internal e2e testing
This commit is contained in:
@@ -38,8 +38,10 @@ To get a local copy up and running, please follow these simple steps.
|
|||||||
```
|
```
|
||||||
2. Run it with Docker
|
2. Run it with Docker
|
||||||
```sh
|
```sh
|
||||||
docker-compose up -d
|
cd tdrive
|
||||||
|
docker compose -f docker-compose.minimal.yml up
|
||||||
```
|
```
|
||||||
|
3. Open <http://localhost/> in a browser
|
||||||
|
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import yargs from "yargs";
|
||||||
|
|
||||||
|
import runWithPlatform from "../../lib/run-with-platform";
|
||||||
|
import gr from "../../../services/global-resolver";
|
||||||
|
import { ConsoleController } from "../../../services/console/web/controller";
|
||||||
|
|
||||||
|
type CLIArgs = {
|
||||||
|
email: string;
|
||||||
|
password: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
command: "set_local_user <email> <password>",
|
||||||
|
describe: "Create or update a local account user and password",
|
||||||
|
builder: {
|
||||||
|
email: {
|
||||||
|
demandOption: true,
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
password: {
|
||||||
|
demandOption: true,
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
handler: async (argv: CLIArgs) => {
|
||||||
|
await runWithPlatform("set_local_user", async ({ spinner: _spinner, platform: _platform }) => {
|
||||||
|
// Validation copied from tdrive/frontend/src/app/views/login/internal/signin/signin.jsx
|
||||||
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(argv.email))
|
||||||
|
throw new Error(`Invalid e-mail ${JSON.stringify(argv.email)}`);
|
||||||
|
if (!(argv.password.length >= 8))
|
||||||
|
throw new Error(`Invalid password ${JSON.stringify(argv.password)}`);
|
||||||
|
await gr.services.users.init();
|
||||||
|
const existingUser = await gr.services.users.getByEmail(argv.email);
|
||||||
|
if (existingUser) {
|
||||||
|
_spinner.info(
|
||||||
|
`Setting password of user ${existingUser.id} (${existingUser.email_canonical})`,
|
||||||
|
);
|
||||||
|
await gr.services.users.setPassword({ id: existingUser.id }, argv.password);
|
||||||
|
} else {
|
||||||
|
_spinner.info(`Creating user with email: ${argv.email}`);
|
||||||
|
await new ConsoleController().signup({
|
||||||
|
body: {
|
||||||
|
email: argv.email,
|
||||||
|
password: argv.password,
|
||||||
|
first_name: "set_local_user firstname",
|
||||||
|
last_name: "set_local_user lastname",
|
||||||
|
},
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
} as any);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
} as yargs.CommandModule<object, CLIArgs>;
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
version: "3.4"
|
||||||
|
|
||||||
|
services:
|
||||||
|
mongo:
|
||||||
|
container_name: mongo
|
||||||
|
image: mongo
|
||||||
|
healthcheck:
|
||||||
|
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
|
||||||
|
interval: 2m
|
||||||
|
timeout: 2m
|
||||||
|
retries: 30
|
||||||
|
start_period: 10s
|
||||||
|
start_interval: 3s
|
||||||
|
volumes:
|
||||||
|
- ./docker-data/mongo:/data/db
|
||||||
|
ports:
|
||||||
|
- 27017:27017
|
||||||
|
|
||||||
|
node_create_user:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/tdrive-node/Dockerfile
|
||||||
|
# target: development
|
||||||
|
target: production
|
||||||
|
container_name: tdrive-node_create_user
|
||||||
|
hostname: tdrive-node_create_user
|
||||||
|
environment: &backend_env_vars
|
||||||
|
- DEV=dev
|
||||||
|
- ACCOUNTS_TYPE=internal
|
||||||
|
- DB_DRIVER=mongodb
|
||||||
|
- DB_MONGO_URI=mongodb://mongo:27017
|
||||||
|
- PUBSUB_TYPE=local
|
||||||
|
- SEARCH_DRIVER=mongodb
|
||||||
|
- STORAGE_DRIVER=local
|
||||||
|
- STORAGE_LOCAL_PATH=/tmp/td
|
||||||
|
- ENABLE_FEATURE_ANTIVIRUS=false
|
||||||
|
- DIAG_PROBE_SECRET=diag-secret
|
||||||
|
|
||||||
|
command: /usr/src/app/bin/twake-cli dev set_local_user a@b.com aaaaaaaa
|
||||||
|
volumes:
|
||||||
|
- ./backend/node/profiles:/usr/src/app/profiles
|
||||||
|
- ./backend/node/src:/usr/src/app/src
|
||||||
|
depends_on:
|
||||||
|
mongo:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
node:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/tdrive-node/Dockerfile
|
||||||
|
# target: development
|
||||||
|
target: production
|
||||||
|
container_name: tdrive-node
|
||||||
|
hostname: tdrive_node
|
||||||
|
ports:
|
||||||
|
- 4000:4000
|
||||||
|
- 9229:9229
|
||||||
|
environment: *backend_env_vars
|
||||||
|
healthcheck:
|
||||||
|
test: curl --fail 'http://localhost:4000/diagnostics/t/ready?secret=diag-secret'
|
||||||
|
volumes:
|
||||||
|
- ./backend/node/profiles:/usr/src/app/profiles
|
||||||
|
- ./backend/node/src:/usr/src/app/src
|
||||||
|
depends_on:
|
||||||
|
mongo:
|
||||||
|
condition: service_healthy
|
||||||
|
node_create_user:
|
||||||
|
condition: service_completed_successfully
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/tdrive-frontend/Dockerfile
|
||||||
|
container_name: tdrive-frontend
|
||||||
|
environment:
|
||||||
|
- DEV=production
|
||||||
|
- SSL_CERTS=off
|
||||||
|
- NODE_HOST=http://node:4000
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
- 443:443
|
||||||
|
depends_on:
|
||||||
|
node:
|
||||||
|
condition: service_healthy
|
||||||
|
# - node
|
||||||
|
volumes:
|
||||||
|
- ./docker-data/logs/nginx/:/var/log/nginx
|
||||||
|
- ./docker-data/letsencrypt/:/etc/letsencrypt/
|
||||||
|
- ./docker-data/drive-preview/:/tdrive-core/web/medias/
|
||||||
|
- ./docker-data/uploads/:/tdrive-core/web/upload/
|
||||||
|
- ./docker-data/ssl:/etc/nginx/ssl
|
||||||
@@ -5,6 +5,7 @@ FROM node:lts-alpine AS node-base
|
|||||||
RUN apk add --update-cache \
|
RUN apk add --update-cache \
|
||||||
ghostscript \
|
ghostscript \
|
||||||
graphicsmagick \
|
graphicsmagick \
|
||||||
|
curl \
|
||||||
&& rm -rf /var/cache/apk/*
|
&& rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user