I have the following Dockerfile_dev docker file:
FROM node:alpine
MAINTAINER "Desyllas Dimitrios"
ENV NEO4J_HOST=""
ENV NEO4J_USER=""
ENV NEO4J_PASSWORD=""
ENV MONGO_CONNECTION_STRING=""
ENV LOGS_DIR="/var/log/data_map"
COPY ./docker_scripts/entrypoint_dev.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh &&\
chown root:root /usr/local/bin/entrypoint.sh &&\
mkdir -p /opt/map &&\
mkdir -p /var/log/data_map &&\
chmod 0666 /var/log/data_map
EXPOSE 7474
VOLUME /var/log/data_map
VOLUME /opt/map
WORKDIR /opt/map
ENTRYPOINT ['/usr/local/bin/entrypoint.sh']
And I have the following entrypoint:
#!/bin/sh
cd /opt/map
npm install
npm start
And the build image is launched via the following docker-compose
version: '2'
services:
data_map_dev:
build:
context: .
dockerfile: Dockerfile_dev
image: 'pcmagas/data-map:dev'
links:
- 'neo4j_dev'
- 'mongodb'
volumes:
- './src:/opt/map/src'
- './www:/opt/map/www'
- './package.json:/opt/map/package.json'
- './docker-volumes/app_dev:/var/log/datamap'
ports:
- "9781:9780"
environment:
NEO4J_HOST: 'neo4j_dev'
NEO4J_USER: 'neo4j'
NEO4J_PASSWORD: 'neo4j'
MONGO_CONNECTION_STRING: 'mongodb://mongodb:map_dev'
neo4j_dev:
image: 'neo4j'
ports:
- '7474:7474'
volumes:
- './docker-volumes/neo4j_dev/data:/data'
environment:
NEO4J_AUTH: 'neo4j/neo45j'
mongodb:
image: 'mongo'
ports:
- '27017:27017'
volumes:
- './docker-volumes/mongodb/:/data/db'
I build it with docker-compose build --no-cache --force-rm and when I launch it via docker-compose up it cannot locate the entrypoint script as you see on the message:
data_map_dev_1 | /bin/sh: [/usr/local/bin/entrypoint.sh]: not found
Do you have any idea why? I have a similar problem on my project too.
Your JSON syntax is wrong.
Note: The exec form is parsed as a JSON array, which means that you must use double-quotes (“) around words not single-quotes (‘).
https://docs.docker.com/engine/reference/builder/
Switch to double quotes like this:
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
Related
I have been trying to deep dive into the problem, but I cannot figure out where everything is going wrong. As you can see below is where the error is happening for this specific rule https://stylelint.io/user-guide/rules/declaration-block-no-redundant-longhand-properties/. Any advice and help would be greatly appreciated :).
node_modules/stylelint/lib/rules/declaration-block-no-redundant-longhand-properties/index.js:117
.map((p) => transformedDeclarationNodes.get(p)?.value.trim())
^
SyntaxError: Unexpected token '.'
my linter config file
{
"extends": "stylelint-config-recommended-scss",
"plugins":["stylelint-prettier"],
"rules": {
"prettier/prettier": true,
"scss/dollar-variable-pattern": null,
"block-no-empty": null,
"rule-empty-line-before":["always",{"ignore":["first-nested"]}],
"scss/selector-no-redundant-nesting-selector": true,
"font-family-no-missing-generic-family-keyword": [true,{"ignoreFontFamilies":["MAIN_THEME"]}],
"color-function-notation": "legacy",
"alpha-value-notation": "number",
"scss/dollar-variable-colon-space-after": "always",
"scss/dollar-variable-colon-space-before": "never",
"unit-allowed-list": ["px","vmin","em","rem","deg","%","vh","vw","s"],
"declaration-block-no-redundant-longhand-properties":[true, {
"severity": "warning"
}],
"selector-class-pattern": "^.*$",
"number-max-precision":2,
"keyframes-name-pattern": "^[a-zA-Z]+?(?:-+[a-zA-Z]{2,10}){1,3}$"
}
}
my CI action file
name: something
on: [pull_request]
jobs:
buildnode:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- uses: actions/setup-node#v3
with:
node-version: '12.x'
- name: install modules
run: npm install
- name: run scss linter
run: npm run styleLinter
- name: run js linter
run: npm run linter
- name: build web app
run: npm run build
- name: test the code
run: npm test
Node version is out of date for styleLint so I updated to 18 that resolved the issue.
When I build my NX monorepo project with Github action workflow, I get the following error:
fatal: No such ref: <COMMIT_HASH>.
This is my build step:
build:
name: Build
needs:
- config
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Pull the full git history
uses: actions/checkout#v3
with:
fetch-depth: 0
- name: Sets the base and head SHAs
uses: nrwl/nx-set-shas#v3
- name: Restore node modules from cache
id: node-modules
uses: actions/cache#v2
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: Install Node.js
uses: actions/setup-node#v2
with:
node-version: '16'
check-latest: true
- run: git fetch
- name: Install node modules
if: ${{ steps.node-modules.outputs.cache-hit != 'true' }}
run: npm ci
- name: Install SAM
uses: aws-actions/setup-sam#v1
- name: Restore repository from cache
uses: actions/cache#v2
with:
path: |
./*
!./node_modules
key: ${{ github.sha }}-run-${{ needs.config.outputs.run-timestamp }}
- name: Cache the build directory
uses: actions/cache#v2
with:
path: ./.aws-sam/*
key: ${{ github.sha }}-build-${{ needs.config.outputs.run-timestamp }}
- name: Build the Lambda
shell: bash
run: npm run affected:build --args='--envType=prod'
The nrwl/nx-set-shas#v3 action injects the base and head automatically to the nx script. The build recognize and prints the base and the head SHAs:
This is my package.json script:
"scripts": {
"prepare": "cd ${pwd} && husky install ${pwd}/.husky",
"lint": "nx lint --verbose",
"affected:lint": "nx affected --target=lint --verbose",
"test": "nx test --verbose",
"affected:test": "nx affected --target=test --verbose",
"build": "nx build --verbose",
"affected:build": "nx affected --target=build --verbose",
"deploy": "nx deploy --verbose",
"affected:deploy": "nx affected --target=deploy --verbose"
}
Any ideas?
We have multiple teams.
Frontend and Backend. All Frontend devs have node on the computer, but not the Backend devs.
Husky (https://typicode.github.io/husky/#/) installs commit-Hooks.
For the Backend devs we get the error message Can't find Husky, skipping pre-commit hook . (Because the have no nodeon their computer).
I don't want them to be forced install node, because we do all that stuff inside of a Docker-Container.
The .git/hooks look like that:
if [ -f "$scriptPath" ]; then
# if [ -t 1 ]; then
# exec < /dev/tty
# fi
if [ -f ~/.huskyrc ]; then
debug "source ~/.huskyrc"
source ~/.huskyrc
fi
node_modules/run-node/run-node "$scriptPath" $hookName "$gitParams"
Or in later versions:
#!/bin/sh
if [ -z "$husky_skip_init" ]; then
debug () {
[ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1"
}
readonly hook_name="$(basename "$0")"
debug "starting $hook_name..."
if [ "$HUSKY" = "0" ]; then
debug "HUSKY env variable is set to 0, skipping hook"
exit 0
fi
if [ -f ~/.huskyrc ]; then
debug "sourcing ~/.huskyrc"
. ~/.huskyrc
fi
export readonly husky_skip_init=1
sh -e "$0" "$#"
exitCode="$?"
if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
exit $exitCode
fi
exit 0
fi
Can i somehow configure husky to that the startup script executes docker-compose run app ....?
I want do run the actual script inside of the container, but I don't get husky itself
to execute in the container.
If I understand you right, I've solved the issue in two steps:
by sharing git from the host with the guest
# at docker-compose.yaml
version: '3'
services:
app:
build:
...
volumes:
- /usr/bin/git:/usr/bin/git
# installing dependencies missing at guest (in my case, guest debian, host ubuntu)
- /lib/x86_64-linux-gnu/libpcre2-8.so.0:/lib/x86_64-linux-gnu/libpcre2-8.so.0
and
2. by running the hook command inside the container, for example:
# at .husky/pre-commit
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
# instead of only npx lint-staged
docker exec great-app npx lint-staged
Testing on docker locally. Custom Dockerfile.
Goal is to execute nightwatch framework tests within Docker with Chrome headless.
I've tried changing chrome arguments
I've tried change chrome binary paths
I've tried changing chrome versions
I build my dockerfile - docker build -t coi-automation .
I docker run -it -p 4444:4444 -v /dev/shm coi-automation:latest
Dockerfile
FROM ubuntu:18.04
RUN apt-get update
#RUN apt-get install --only-upgrade bash
#RUN apt-get install --only-upgrade curl
#RUN apt-get install --only-upgrade sed
#RUN apt-get install --only-upgrade git
RUN ln -s /bin/bash /usr/bin/bash && ln -s /bin/sed /usr/bin/sed && ln -s /bin/sh /usr/bin/sh
RUN apt-get install -y --no-install-recommends software-properties-common
RUN add-apt-repository -y ppa:openjdk-r/ppa
RUN apt-get update
RUN apt-get install -y openjdk-8-jdk
RUN apt-get install -y openjdk-8-jre
RUN update-alternatives --config java
RUN update-alternatives --config javac
RUN apt update \
&& apt install -y \
curl \
bash \
git \
sed \
gnupg \
gcc \
g++ \
make \
&& curl -sL https://deb.nodesource.com/setup_10.x | bash - \
&& apt install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
# Install Chrome for Selenium
RUN curl https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o /chrome.deb
RUN dpkg -i /chrome.deb || apt-get install -yf
RUN rm /chrome.deb
# Install chromedriver for Selenium
RUN curl https://chromedriver.storage.googleapis.com/2.31/chromedriver_linux64.zip -o /usr/local/bin/chromedriver
RUN chmod +x /usr/local/bin/chromedriver
COPY ./ ./
RUN npm install
EXPOSE 4444
nightwatch.json:
{
"src_folders" : ["./tests"],
"output_folder" : "./test-results",
"custom_commands_path" : "./custom_commands",
"page_objects_path" : "./page",
"custom_assertions_path" : "",
"globals_path" : "",
"live_output" : false,
"disable_colors": false,
"selenium" : {
"start_process" : true,
"server_path" : "./node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.8.1.jar",
"log_path" : "",
"port" : 4444,
"cli_args" : {
"webdriver.gecko.driver" : "./node_modules/geckodriver/bin/geckodriver",
"webdriver.chrome.driver" : "./node_modules/chromedriver/bin/chromedriver"
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions" : {
"args" : [
"--window-size=1325x744",
"--disable-gpu",
"--headless",
"--no-sandbox",
"--ignore-certificate-errors"],
"binary": "/usr/bin/google-chrome"
},
"javascriptEnabled": true,
"acceptSslCerts": true,
"loggingPrefs": { "browser": "ALL" }
}
}
},
"globals" : {
"waitForConditionTimeout": 5000,
"retryAssertionTimeout": 20000
}
}
Error:
>
root#0dd3100c6606:/# npm test
> coi-automation#1.0.0 test /
> nightwatch
[Smoketests/Coi Smoke Tests] Test Suite
=======================================
Response 500 POST /wd/hub/session (1035ms)
{ value:
{ error:
[ ' (unknown error: DevToolsActivePort file doesn\'t exist)',
' (The process started from chrome location ./node_modules/chromedriver/bin/chromedriver is no longer running, so ChromeDriver is assuming that Chrome has crashed.)',
' (Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.9.125-linuxkit x86_64) (WARNING: The server did not provide any stacktrace information)',
'Command duration or timeout: 194 milliseconds',
'Build info: version: \'3.8.1\', revision: \'6e95a6684b\', time: \'2017-12-01T19:05:32.194Z\'',
'System info: host: \'0dd3100c6606\', ip: \'172.17.0.2\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'4.9.125-linuxkit\', java.version: \'1.8.0_212\'',
'Driver info: driver.version: unknown' ],
message: 'unknown error: Chrome failed to start: exited abnormally' },
status: 13 }
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally"
at endReadableNT (_stream_readable.js:1125:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
_________________________________________________
TEST FAILURE: 1 error during execution 0 tests failed, 0 passed. 2.128s
I am trying to pass argument in my npm command and use that argument in my script
Example:
npm run test -b chrome -e QA
"scripts": {
"test": "something.js ./xyz/abc/cdf --something \"{\\\"browser\\\": \\\"<process.argv[2]>\\\"}\""
}
I am not sure, how to access in my script.
Please advice
In something.js you can access the process arguments by process.argv.
It will be an array of x elements, where the first two are the executable running your script and the second is a path to the script that is being ran.
Try console.log(process.argv); to see whats up.
In your specific example you should remove the escaped " characters to get it working, like so:
running node in terminal
node somethings.js ./xyz/abc/cdf --something "{\\\"browser\\\": \\\"<process.argv[2]>\\\"}"
Results in:
[ '/usr/local/bin/node',
'/Users/user/Documents/test.js',
'./xyz/abc/cdf',
'--something',
'{\\"browser\\": \\"<process.argv[2]>\\"}' ]
package.json script
"scripts": {
"test": "node test.js"
},
Note: add node as the executable in the test script
Running npm run test -b chrome -e QA
Results in:
[ '/usr/local/bin/node',
'/Users/user/Documents/test.js',
'chrome',
'QA' ]
If you'd like to get the -b and -e arguments in there too, add --. Like so:
npm run test -- -b chrome -e QA
Results in
[ '/usr/local/bin/node',
'/Users/user/Documents/test.js',
'-b',
'chrome',
'-e',
'QA' ]