1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-12-08 00:45:29 +01:00

refactor: no duplicate of package.json in solutions

This commit is contained in:
Divlo 2021-12-06 19:04:16 +01:00
parent cffaa9ec40
commit 938702c23f
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9
13 changed files with 42 additions and 31 deletions

View File

@ -1,3 +0,0 @@
{
"type": "module"
}

View File

@ -1,3 +0,0 @@
{
"type": "module"
}

View File

@ -1,3 +0,0 @@
{
"type": "module"
}

View File

@ -1,3 +0,0 @@
{
"type": "module"
}

View File

@ -1,3 +0,0 @@
{
"type": "module"
}

View File

@ -3,6 +3,7 @@ import ora from 'ora'
class Docker {
static CONTAINER_TAG = 'programming-challenges'
static SIGSEGV_EXIT_CODE = 139
public async build (): Promise<void> {
const loader = ora('Building the Docker image').start()
@ -22,11 +23,18 @@ class Docker {
input
}
)
try {
const { stdout, stderr } = await subprocess
if (stderr.length !== 0) {
throw new Error(stderr)
}
return stdout
} catch (error: any) {
if (error.exitCode === Docker.SIGSEGV_EXIT_CODE) {
throw new Error('Docker run failed: SIGSEGV indicates a segmentation fault (attempts to access a memory location that it\'s not allowed to access).')
}
throw new Error(`Docker run failed: ${error.message as string}`)
}
}
}

View File

@ -1,4 +1,8 @@
FROM node:16.13.1
RUN npm install --global ts-node typescript @types/node
COPY ./ ./
CMD ["ts-node", "solution.ts"]
WORKDIR /usr/app
COPY ./ /usr/app
RUN npm install
RUN npm run build
CMD ["node", "build/solution.js"]

View File

@ -0,0 +1,10 @@
{
"type": "module",
"scripts": {
"build": "tsc"
},
"devDependencies": {
"@types/node": "latest",
"typescript": "latest"
}
}

View File

@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"lib": ["ESNext"],
"moduleResolution": "node",
"outDir": "./build",
"rootDir": "./",
"strict": true,
"skipLibCheck": true,
"esModuleInterop": true
}
}