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:
parent
cffaa9ec40
commit
938702c23f
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module"
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module"
|
|
||||||
}
|
|
@ -3,6 +3,7 @@ import ora from 'ora'
|
|||||||
|
|
||||||
class Docker {
|
class Docker {
|
||||||
static CONTAINER_TAG = 'programming-challenges'
|
static CONTAINER_TAG = 'programming-challenges'
|
||||||
|
static SIGSEGV_EXIT_CODE = 139
|
||||||
|
|
||||||
public async build (): Promise<void> {
|
public async build (): Promise<void> {
|
||||||
const loader = ora('Building the Docker image').start()
|
const loader = ora('Building the Docker image').start()
|
||||||
@ -22,11 +23,18 @@ class Docker {
|
|||||||
input
|
input
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const { stdout, stderr } = await subprocess
|
try {
|
||||||
if (stderr.length !== 0) {
|
const { stdout, stderr } = await subprocess
|
||||||
throw new Error(stderr)
|
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}`)
|
||||||
}
|
}
|
||||||
return stdout
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
FROM node:16.13.1
|
FROM node:16.13.1
|
||||||
RUN npm install --global ts-node typescript @types/node
|
|
||||||
COPY ./ ./
|
WORKDIR /usr/app
|
||||||
CMD ["ts-node", "solution.ts"]
|
COPY ./ /usr/app
|
||||||
|
RUN npm install
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
CMD ["node", "build/solution.js"]
|
||||||
|
10
templates/docker/typescript/package.json
Normal file
10
templates/docker/typescript/package.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "latest",
|
||||||
|
"typescript": "latest"
|
||||||
|
}
|
||||||
|
}
|
13
templates/docker/typescript/tsconfig.json
Normal file
13
templates/docker/typescript/tsconfig.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ESNext",
|
||||||
|
"module": "ESNext",
|
||||||
|
"lib": ["ESNext"],
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"outDir": "./build",
|
||||||
|
"rootDir": "./",
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": true
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user