diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..41883ba0 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "attach", + "name": "Attach to Remote", + "address": "localhost", + "port": 9229, + "restart": true, + "sourceMaps": true, + "remoteRoot": "/app", + "localRoot": "${workspaceFolder}", + "resolveSourceMapLocations": [ + "${workspaceFolder}/**", + "!**/node_modules/**" + ] + } + ] +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index b03ba9d1..5579607c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,21 @@ -ARG IMAGE_VERSION="latest" -FROM 416670754337.dkr.ecr.eu-west-2.amazonaws.com/ci-node-runtime-20:${IMAGE_VERSION} +FROM node:20 -RUN cp -r ./dist/* ./ && rm -rf ./dist -RUN ls -CMD ["./server.js","--","3000"] -EXPOSE 3000 +ARG SSH_KEY +ENV SSH_KEY=$SSH_KEY +# Make ssh dir +RUN mkdir /root/.ssh/ +# Create id_rsa from string arg, and set permissions +RUN echo "$SSH_KEY" >/root/.ssh/id_rsa +RUN chmod 600 /root/.ssh/id_rsa +# Create known_hosts +RUN touch /root/.ssh/known_hosts +# Add git providers to known_hosts +RUN ssh-keyscan bitbucket.org >>/root/.ssh/known_hosts +RUN ssh-keyscan github.com >>/root/.ssh/known_hosts +RUN ssh-keyscan gitlab.com >>/root/.ssh/known_hosts +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +CMD [ "npm", "run", "start:watch" ] +# ENTRYPOINT [ "bash" ] diff --git a/Dockerfile.dev b/Dockerfile.dev deleted file mode 100644 index 4fe3dec7..00000000 --- a/Dockerfile.dev +++ /dev/null @@ -1,20 +0,0 @@ -FROM node:20 -ARG SSH_KEY -ENV SSH_KEY=$SSH_KEY -# Make ssh dir -RUN mkdir /root/.ssh/ -# Create id_rsa from string arg, and set permissions -RUN echo "$SSH_KEY" > /root/.ssh/id_rsa -RUN chmod 600 /root/.ssh/id_rsa -# Create known_hosts -RUN touch /root/.ssh/known_hosts -# Add git providers to known_hosts -RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts -RUN ssh-keyscan github.com >> /root/.ssh/known_hosts -RUN ssh-keyscan gitlab.com >> /root/.ssh/known_hosts -WORKDIR /app -COPY package*.json ./ -RUN npm install -COPY . . -CMD [ "npm", "run", "start:watch" ] -# ENTRYPOINT [ "bash" ] diff --git a/Tiltfile.dev b/Tiltfile.dev index 44677c21..847c387a 100644 --- a/Tiltfile.dev +++ b/Tiltfile.dev @@ -1,7 +1,7 @@ custom_build( ref = '416670754337.dkr.ecr.eu-west-2.amazonaws.com/psc-verification-web:latest', #the following build-command was updated as specified by https://github.com/companieshouse/docker-chs-development/pull/581 - command = 'DOCKER_BUILDKIT=0 docker build --build-arg SSH_PRIVATE_KEY="$(ssh_key_path="$(ssh -G github.com | grep -e \'^identityfile.*\' | head -n1 | sed \'s|^identityfile \\(.*\\)|\\1|\')"; if [ -z "${ssh_key_path}" ]; then echo "Could not find ssh key path for github.com">&2; false; elif [ -f "${ssh_key_path}" ]; then cat "${ssh_key_path}"; else echo "Could not find ssh key for github at ${ssh_key_path}" >&2; false; fi)" --build-arg SSH_PRIVATE_KEY_PASSPHRASE --tag $EXPECTED_REF . -f Dockerfile.dev', + command = 'DOCKER_BUILDKIT=0 docker build --build-arg SSH_PRIVATE_KEY="$(ssh_key_path="$(ssh -G github.com | grep -e \'^identityfile.*\' | head -n1 | sed \'s|^identityfile \\(.*\\)|\\1|\')"; if [ -z "${ssh_key_path}" ]; then echo "Could not find ssh key path for github.com">&2; false; elif [ -f "${ssh_key_path}" ]; then cat "${ssh_key_path}"; else echo "Could not find ssh key for github at ${ssh_key_path}" >&2; false; fi)" --build-arg SSH_PRIVATE_KEY_PASSPHRASE --tag $EXPECTED_REF .', live_update = [ sync(local_path = './src', remote_path = '/app/src'), run('npm install', trigger=['./package.json', './package-lock.json']) @@ -10,4 +10,4 @@ custom_build( './src', './src/views' ] -) \ No newline at end of file +) diff --git a/package.json b/package.json index 8673913f..26c93419 100755 --- a/package.json +++ b/package.json @@ -115,7 +115,7 @@ "ignore": [ "**/*.test.ts" ], - "exec": "npm run build && node dist/server.js" + "exec": "npm run build && node --inspect=0.0.0.0:9229 dist/server.js" }, "directories": { "test": "test"