diff --git a/.gitignore_recorder b/.gitignore_recorder index 7d1a7b68fe94a670b1ee7e52632e231478e013f0..2447eff3a26057275ced9afce3380441674df89a 100644 --- a/.gitignore_recorder +++ b/.gitignore_recorder @@ -123,9 +123,6 @@ typings/ # Yarn Integrity file .yarn-integrity -# dotenv environment variables file -.env -.env.test # parcel-bundler cache (https://parceljs.org/) .cache diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4e98ba2e372a681c7f83e4e702d0c62adac1e9ff..c7ac262d6035dadebd033796f87850c7266c9ff0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,7 @@ +variables: + EXTENSION_PATH: "./deadlock-plugins/deadlock-extension" + REGISTRY: "registry.takima.io" + stages: - build - publish @@ -13,24 +17,23 @@ build: stage: build services: - docker:18.09.6-dind - parallel: - matrix: - - VERSION: [code, kube, desktop] + variables: + VERSION: "desktop" script: - - ./build.sh $TAG $VERSION $CI_REGISTRY_IMAGE - - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.e-biz.fr + - ./build.sh $TAG desktop $CI_REGISTRY_IMAGE + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $REGISTRY - docker push $CI_REGISTRY_IMAGE/$VERSION:$TAG rules: - - if: $CI_COMMIT_BRANCH == "main" + - if: $CI_COMMIT_BRANCH == "develop" - if: $CI_COMMIT_TAG != null - - desktop_extension:package:pre-release: stage: build cache: paths: - - ./deadlock-plugins/deadlock-extension/ + - $EXTENSION_PATH policy: push + before_script: + - npm install --prefix script: - ./build-desktop.sh staging rules: @@ -42,10 +45,10 @@ desktop_extension:publish:pre-release: stage: publish cache: paths: - - ./deadlock-plugins/deadlock-extension/ + - $EXTENSION_PATH policy: pull script: - - cd ./deadlock-plugins/deadlock-extension + - cd $EXTENSION_PATH - npm run vsce-publish -- --pre-release -p $VSCODE_EXTENSION_MARKET_PLACE_ACCESS_TOKEN rules: - if: $CI_COMMIT_BRANCH == "develop" @@ -56,9 +59,10 @@ desktop_extension:package:release: stage: build cache: paths: - - ./deadlock-plugins/deadlock-extension/ + - $EXTENSION_PATH policy: push - + before_script: + - npm install --prefix $EXTENSION_PATH script: - ./build-desktop.sh prod rules: @@ -68,10 +72,10 @@ desktop_extension:publish:release: stage: publish cache: paths: - - ./deadlock-plugins/deadlock-extension/ + - $EXTENSION_PATH policy: pull script: - - cd ./deadlock-plugins/deadlock-extension + - cd $EXTENSION_PATH - npm run vsce-publish -- -p $VSCODE_EXTENSION_MARKET_PLACE_ACCESS_TOKEN rules: - if: $CI_COMMIT_TAG =~ /(?:\d+.){2}(?:\d+)*(2|4|6|8|0)$/ # If tag is like X.Y.Z and Z is even diff --git a/Dockerfile.code b/Dockerfile.code deleted file mode 100644 index 02e18de9e81209f3c2a0a9a9cba8cc3a247a9849..0000000000000000000000000000000000000000 --- a/Dockerfile.code +++ /dev/null @@ -1,28 +0,0 @@ -FROM registry.e-biz.fr/deadlock-public/theia:1.22.1-java - -USER root - -RUN apt update -RUN apt upgrade -y -RUN apt install rsync -y -RUN apt install vim -y - -COPY plugins /home/plugins -COPY default/.theia/ /home/theia/.theia/ -RUN chown theia /home/theia/.theia -R -RUN chown theia /home/plugins -R - -COPY server.js /home/theia/src-gen/backend/server.js - -COPY recorder-out/ deadlock/ -COPY .gitignore_recorder deadlock/.gitignore - -COPY setup_trace.py . -RUN chmod 700 setup_trace.py -RUN chown theia setup_trace.py - -COPY start.sh . -RUN chmod 504 deadlock/ -R -RUN chmod 500 start.sh - -ENTRYPOINT ["bash", "start.sh"] diff --git a/Dockerfile.desktop b/Dockerfile.desktop index 23c2ddf46d9c9c3c7d54d62b1bdffb2edda0dc2d..d66dc517d5d553616d0f0fbbd07785748abb631e 100644 --- a/Dockerfile.desktop +++ b/Dockerfile.desktop @@ -1,32 +1,36 @@ -FROM node:alpine3.15 +FROM node:16.15 -RUN apk update -RUN apk --no-cache add vim && apk --no-cache add nano \ - && apk --no-cache add rsync && apk --no-cache add sudo \ - && apk --no-cache add bash && apk --no-cache add openssh \ - && apk --no-cache add git && apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python +RUN apt update -y +RUN apt install vim -y && apt install nano -y \ + && apt install rsync -y && apt install sudo -y \ + && apt install bash -y && apt install openssh-server -y \ + && apt install git -y && apt install python3 -y \ + && ln -sf python3 /usr/bin/python && apt install g++ -y ## User account -RUN addgroup -S sudo && adduser --disabled-password --gecos '' deadlock && \ - adduser deadlock sudo && \ - echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +RUN adduser --disabled-password --gecos '' deadlock && \ + usermod -aG sudo deadlock && passwd -d deadlock -COPY setup_trace_desktop.py setup_trace.py +COPY setup_trace.py setup_trace.py RUN chmod 700 setup_trace.py RUN chown deadlock setup_trace.py COPY recorder-out deadlock/ COPY .gitignore_recorder deadlock/.gitignore - - COPY start.desktop.sh . RUN chmod 504 deadlock/ -R RUN chmod 500 start.desktop.sh -RUN mkdir /project && mkdir /tmp/.ssh && mkdir /home/deadlock/mission +RUN mkdir /project && mkdir /tmp/.ssh && mkdir /home/deadlock/mission && \ + chown deadlock:deadlock /home/deadlock + +RUN curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh +RUN curl -SL https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose && \ + chmod +x /usr/local/bin/docker-compose && \ + ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose -RUN chown deadlock:deadlock /home/deadlock +RUN usermod -aG docker deadlock ENTRYPOINT ["bash", "start.desktop.sh"] \ No newline at end of file diff --git a/Dockerfile.kube b/Dockerfile.kube deleted file mode 100644 index 7287ba049b47c0fea230a24b9f832056ab5281f1..0000000000000000000000000000000000000000 --- a/Dockerfile.kube +++ /dev/null @@ -1,7 +0,0 @@ -FROM registry.e-biz.fr/deadlock-public/deadlock-theia:1.4 - -RUN apt-get install -y apt-transport-https -RUN curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - -RUN echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list -RUN apt-get update -RUN apt-get install -y kubectl \ No newline at end of file diff --git a/build-recorder.sh b/build-recorder.sh index cd2cf4cebc367b36e3acc645f4a57ae263f0e401..bdf979661c346d6b483aa9f5777f1f0e3f4e5430 100755 --- a/build-recorder.sh +++ b/build-recorder.sh @@ -8,11 +8,9 @@ cd ./deadlock-plugins/deadlock-extension/ npm install npm run build-recorder -npm run build-preStop cd - mkdir -p $OUTPUT_DIR cp -r ./deadlock-plugins/deadlock-extension/out/recorder.js $OUTPUT_DIR -cp -r ./deadlock-plugins/deadlock-extension/out/preStop.js $OUTPUT_DIR diff --git a/deadlock-plugins/deadlock-extension/src/core/mission.ts b/deadlock-plugins/deadlock-extension/src/core/mission.ts index a684dbbcfa5f5f80b8050703182a7666c4eecdb9..8a4d7118406b8bd22ed53805ce13ef62d7d07f58 100644 --- a/deadlock-plugins/deadlock-extension/src/core/mission.ts +++ b/deadlock-plugins/deadlock-extension/src/core/mission.ts @@ -20,17 +20,25 @@ export default class Mission { private readonly remoteUserHomeDir: string; private readonly remoteMissionDir: any; private readonly remoteGiteaWorkDir: string; - constructor(private params: { registryBaseURL: string; missionId: string; missionVersion: string }) { + private readonly userConfigPath: string; + private readonly userSshPath: string; + constructor( + private params: { registryBaseURL: string; missionId: string; missionVersion: string }, + userSshPath: string, + ) { const { registryBaseURL, missionId, missionVersion } = params; this.hostBaseWorkDir = ExtensionStore.getInstance().getMissionWorkdir() ?? ''; this.hostMissionDir = `${this.hostBaseWorkDir}/${missionId}`; + // TODO: NEED TO BE MOCK FOR MOMENT : WAITING US#8 + this.userConfigPath = '/home/lansana/Documents/deadlock/deadlock-theia/config'; //`${this.hostMissionDir}/.userConfig`; + this.userSshPath = '/home/lansana/Documents/deadlock/deadlock-theia/ssh'; // userSshPath this.hostMissionDevcontainerDir = `${this.hostMissionDir}/.devcontainer`; this.hostMissionDevcontainerFileDir = `${this.hostMissionDevcontainerDir}/devcontainer.json`; this.hostMissionMountDir = `${this.hostMissionDir}/mounted`; this.dockerImageURL = getDockerImageURL(registryBaseURL, missionId, missionVersion); this.remoteUserHomeDir = '/home/deadlock'; this.remoteMissionDir = `${this.remoteUserHomeDir}/mission`; - this.remoteGiteaWorkDir = `/project`; + this.remoteGiteaWorkDir = `/src`; } static async pullImage(url) { @@ -50,9 +58,10 @@ export default class Mission { image: this.dockerImageURL, extensions: ['Deadlock.deadlock-coding'], remoteUser: 'deadlock', - // mounts: [ - // `source=${this.hostMissionDir}/workspace,target=${'/workspace'},type=${'volume'},consistency=${'cached'}`, - // ], + mounts: [ + `source=${this.userSshPath},target=/tmp/.ssh,type=bind,consistency=cached`, + `source=${this.userConfigPath},target=/home/config/,type=bind,consistency=cached`, + ], userEnvProbe: 'interactiveShell', settings: { 'terminal.integrated.defaultProfile.linux': 'bash', @@ -67,6 +76,13 @@ export default class Mission { workspaceMount: `source=${this.hostMissionMountDir},target=${this.remoteMissionDir},type=bind`, workspaceFolder: `${this.remoteMissionDir}`, onCreateCommand: `cp -R ${this.remoteGiteaWorkDir} ${this.remoteMissionDir}`, + features: { + 'docker-from-docker': { + version: 'latest', + moby: true, + dockerDashComposeVersion: 'v1', + }, + }, ...options, }; return JSON.stringify(devcontainer, null, 2); diff --git a/deadlock-plugins/deadlock-extension/src/recorder/command-recorder.ts b/deadlock-plugins/deadlock-extension/src/recorder/command-recorder.ts index 85bdbf9b52fb879aeff2b8a7071ef755231920e5..f770af06dd3e4335945826a93a80f79f1f524590 100644 --- a/deadlock-plugins/deadlock-extension/src/recorder/command-recorder.ts +++ b/deadlock-plugins/deadlock-extension/src/recorder/command-recorder.ts @@ -1,7 +1,7 @@ import GitMission from '../core/gitMission'; -import { error, commitAndPushCode, CommitFrom, log, updateRemote } from './utils'; -const async = require('async'); -const fs = require('fs'); +import { error, CommitFrom, updateRemote } from './utils'; +import * as async from 'async'; +import * as fs from 'fs'; class Command { public still: boolean; diff --git a/deadlock-plugins/deadlock-extension/src/recorder/services/file-watcher.ts b/deadlock-plugins/deadlock-extension/src/recorder/services/file-watcher.ts index 3a786802615d939f6f5e1b91c6f579d2aa425773..b46e7a142396970c3f7c7b56f845a6da4a1523d8 100644 --- a/deadlock-plugins/deadlock-extension/src/recorder/services/file-watcher.ts +++ b/deadlock-plugins/deadlock-extension/src/recorder/services/file-watcher.ts @@ -1,4 +1,4 @@ -const chokidar = require('chokidar'); +import * as chokidar from 'chokidar'; export default class FileWatcher { constructor( @@ -11,11 +11,13 @@ export default class FileWatcher { } setupWatcher() { - const watcher = chokidar.watch(this.watchFilePatterns, { - ignoreInitial: true, - cwd: this.folderToWatch, - ignored: this.ignoreFilePatterns, - }); - watcher.on('all', this.onFilesChangeAction); + // Without timeout, chokidar watch when file is init + setTimeout(() => { + const watcher = chokidar.watch(this.watchFilePatterns, { + cwd: this.folderToWatch, + ignored: this.ignoreFilePatterns, + }); + watcher.on('change', this.onFilesChangeAction); + }, 1000); } } diff --git a/deadlock-plugins/deadlock-extension/src/recorder/services/http-server.ts b/deadlock-plugins/deadlock-extension/src/recorder/services/http-server.ts index 6c3d474cecb8c51c26176c519fe1b8b6adf52768..ab7a5d5b106be9dce73919780f00a704d960ecba 100644 --- a/deadlock-plugins/deadlock-extension/src/recorder/services/http-server.ts +++ b/deadlock-plugins/deadlock-extension/src/recorder/services/http-server.ts @@ -3,7 +3,6 @@ import { Express } from 'express'; import { updateRemote, CommitFrom, log } from '../utils'; import { HTTP_SERVER_PORT } from '../../config'; const express = require('express'); - export default class HttpServer { app: Express; diff --git a/plugins/gitlens-10.2.3.vsix b/plugins/gitlens-10.2.3.vsix deleted file mode 100644 index 248629ac5c2accb40160dfc108b9026f43869ed2..0000000000000000000000000000000000000000 Binary files a/plugins/gitlens-10.2.3.vsix and /dev/null differ diff --git a/setup_trace.py b/setup_trace.py index 313589500a92f3dd57d6be106950d9382fe7a730..80f70c3c9d60d86bda52a33a14a72ccac9379fae 100644 --- a/setup_trace.py +++ b/setup_trace.py @@ -1,7 +1,7 @@ -open('/home/theia/.bash_history', 'a').close() +open('/home/deadlock/.bash_history', 'a').close() -bashrc = open('/home/theia/.bashrc', 'a') +bashrc = open('/home/deadlock/.bashrc', 'a') bashrc.write('\n') bashrc.write('HISTCONTROL=""') bashrc.write('\n') diff --git a/setup_trace_desktop.py b/setup_trace_desktop.py deleted file mode 100644 index 80f70c3c9d60d86bda52a33a14a72ccac9379fae..0000000000000000000000000000000000000000 --- a/setup_trace_desktop.py +++ /dev/null @@ -1,12 +0,0 @@ - -open('/home/deadlock/.bash_history', 'a').close() - -bashrc = open('/home/deadlock/.bashrc', 'a') -bashrc.write('\n') -bashrc.write('HISTCONTROL=""') -bashrc.write('\n') -bashrc.write("PROMPT_COMMAND='history -a'") -bashrc.write('\n') - -# Close the file -bashrc.close() \ No newline at end of file diff --git a/start.sh b/start.sh deleted file mode 100755 index c45a90336ab9b77e6160e4c17e4341791922076f..0000000000000000000000000000000000000000 --- a/start.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -ON_START_UP_FILE="/deadlock/startup.sh" -TAG="[DEADLOCK]" - -# setup ssh key for root user -# must be installed by the API first within /tmp/.ssh -mkdir ~/.ssh -cp /tmp/.ssh/* ~/.ssh/ - -# start init mission script if exists -if [ -f "$ON_START_UP_FILE" ]; then - echo - echo "$TAG Startup your script.." - echo - /bin/bash $ON_START_UP_FILE & -else - echo - echo "$TAG No startup script found." - echo -fi - -# start command recorder -node deadlock/recorder.js & - -deluser theia sudo - -su theia --command "python setup_trace.py" -rm setup_trace.py - -# starting theia as THEIA -su theia --command "node /home/theia/src-gen/backend/main.js /home/project --hostname=0.0.0.0 --plugins=local-dir:/home/plugins"