golang dlv unable to see source:: no such file or directory - delve

In a docker container:
docker run \
--rm -it \
-p 80:80 \
-p 2345:2345 \
-v $(pwd)/src:/go/src/ \
--security-opt="seccomp=unconfined" \
--privileged \
--cap-add SYS_PTRACE \
golang bash
In the container at $GOPATH:
go get -u github.com/derekparker/delve/cmd/dlv
dlv version
Delve Debugger
Version: 1.1.0
Build: $Id: 1990ba12450cab9425a2ae62e6ab988725023d5c
dlv debug app --headless --listen=0.0.0.0:2345 --api-version=2
In mac terminal at $GOPATH::
dlv version
Delve Debugger
Version: 1.1.0
Build: $Id: 1990ba12450cab9425a2ae62e6ab988725023d5c $
dlv connect 127.0.0.1:2345
I get the following, but unable to list source?
dlv connect 127.0.0.1:2345
Type 'help' for list of commands.
(dlv) b main.go:29
Breakpoint 1 set at 0x7f584d for main.main.func1() /go/src/app/main.go:29
(dlv) c
> main.main.func1() /go/src/app/main.go:29 (hits goroutine(4):1 total:1) (PC: 0x7f584d)
(dlv) l
> main.main.func1() /go/src/app/main.go:29 (hits goroutine(4):1 total:1) (PC: 0x7f584d)
Command failed: open /go/src/app/main.go: no such file or directory
Note: I am in $GOPATH in both the dlv server and client:
In container:
ls $GOPATH/src/app
layout.html main.go mypack
In mac terminal:
ls $GOPATH/src/app
layout.html main.go mypack
vs code launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Connect to server",
"type": "go",
"request": "launch",
"mode": "remote",
"remotePath": "${workspaceFolder}",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceFolder}",
"env": {},
"args": [],
"trace": "verbose"
},
]
}

See https://github.com/go-delve/delve/issues/1438. Solution is to put this in
$HOME/.dlv/config.yml:
substitute-path:
- {from: /, to: /root}

On my Ubuntu 18.04 I see the location of the file as ~/.config/dlv/config.yml. Here is an example:
substitute-path:
- {from: /code, to: /home/foo/git/repo}

I wanted to add to the answers above that you do not necessarily need to create a config.yaml file to set substitute-path, you can also do so from inside dlv shell by running: config substitute-path / /root

Related

'npm run serve' is not initiallizing project in browser

I am running 'npm run serve' command to execute my vue project in browser . But it is not giving any output or error it just keep running
enter image description here
it just stucks here only
I have tried every thing I have restarted my system and reinstalled vue-cli also but it it didn't worked.
I was running perfectly fine yesterday but today it's not working in fact it wasted my whole day
What did I try
Execute 'npm run serve' cmd
What I Expect
To open my project in Browser
npm run serve will run the built version of your project. It sound to me like you want to run it locally in the browser (for dev and testing) and should use npm run dev.
npm run serve will only serve the output of a npm run build command, and is usually only run after deploying to an actual server.
{
"name": "fer-07-project",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"lint": "eslint --fix --ext .js,.jsx .",
"init-project": "npm install && npm-run-all init:*",
"init:dirs": "mkdirp dist src/sass src/css src/vendor src/images src/js",
"init:files": "touch README.md src/index.html src/sass/style.scss src/js/script.js",
"init:gitignore": "curl https://raw.githubusercontent.com/github/gitignore/master/Node.gitignore -o .gitignore",
"init:gitignore:custom": "echo \"dist\" >> .gitignore",
"test": "npm-run-all test:*",
"test:html": "globstar nu-html-checker dist/*.html",
"test:js": "eslint src/js/ --fix",
"test:scss": "stylelint src/sass/",
"build": "npm-run-all build:* test",
"build:clean": "mkdirp dist && rm -r dist && mkdirp dist",
"build:copy": "copyfiles -a -u 1 -e \"**/sass/**/*\" -e \"**/.gitkeep\" \"src/**/*\" dist",
"build:sass": "node-sass --output-style compact -o dist/css src/sass",
"build:autoprefixer": "globstar autoprefixer-cli \"dist/css/*.css\"",
"build-dev": "npm-run-all build-dev:sass build:autoprefixer",
"build-dev:sass": "node-sass --output-style expanded --source-map true -o dist/css src/sass",
"server": "json-server --port 3131 --no-cors --delay 250 --watch dist/db/app.json",
"watch": "npm-run-all build build-dev -p watch:* server",
"watch:browsersync": "browser-sync start --server dist --files \"dist/**/*\" --ignore \"dist/db/**/*\"",
"watch:sassprefixer": "onchange \"src/sass/**/*.scss\" -- npm run build-dev",
"watch:copy": "onchange -e \"**/sass/**/*\" -e \"**/.gitkeep\" \"src/**/*\" -- copyfiles -a -u 1 {{changed}} dist"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"flatpickr": "^4.6.9",
"json-server": "^0.16.3",
"rangeslider-pure": "^0.4.11"
},
"devDependencies": {
"autoprefixer-cli": "^1.0.0",
"browser-sync": "^2.26.3",
"copyfiles": "^2.1.0",
"eslint": "^5.14.1",
"globstar": "^1.0.0",
"mkdirp": "^0.5.1",
"node-sass": "^4.11.0",
"npm-run-all": "^4.1.5",
"nu-html-checker": "^0.1.0",
"onchange": "^5.2.0",
"stylelint": "^9.10.1",
"stylelint-scss": "^3.5.4"
}
}

Create mongo image having initial collections with docker file

I am trying to create a custom mongo image from the official image with few custom collections baked into the image.
I have created a init script that runs and import json into the database using mongoimport.
Docker file builds correctly and I can see the scripts runs successfully.
But when i run the container with the generated image I am unable to see the added collecitons.
Docker file:
FROM mongo:latest
RUN mkdir -p /data/db2 \
&& echo "dbpath = /data/db2" > /etc/mongodb.conf \
&& chown -R mongodb:mongodb /data/db2
COPY ./upload.json /json/
COPY ./init.sh .
RUN ./init.sh
VOLUME /data/db2
CMD ["mongod", "--config", "/etc/mongodb.conf"]
#docker build -f Dockerfile -t my-mongo/test:1.0 .
init.sh:
#!/usr/bin/env bash
mongod --fork --logpath /var/log/mongodb.log --dbpath /data/db2
mongoimport -d testStore -c authors --file ./json/upload.json --jsonArray
mongod --dbpath /data/db2 --shutdown
upload.json:
[
{ "Name": "Design Patterns", "Price": 54.93, "Category": "Computers", "Author": "Ralph Johnson" },
{ "Name": "Clean Code", "Price": 43.15, "Category": "Computers", "Author": "Robert C. Martin" }
]

How do I add Pulumi to my GitHub Codespaces / VSCode .NET devcontainer?

I want to develop and deploy IaC with Pulumi .NET / C# from a VS Code .devcontainer. How can I add this capability to the environment?
I included the build container steps from https://github.com/pulumi/pulumi-docker-containers/blob/main/docker/dotnet/Dockerfile into .devcontainer/Dockerfile:
ARG DOTNET_VARIANT="3.1"
ARG PULUMI_VERSION=latest
ARG INSTALL_NODE="true"
ARG NODE_VERSION="lts/*"
# --------------------------------------------------------------------------------
FROM debian:11-slim AS builder
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get install -y \
curl \
build-essential \
git
RUN if [ "$PULUMI_VERSION" = "latest" ]; then \
curl -fsSL https://get.pulumi.com/ | bash; \
else \
curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION ; \
fi
# --------------------------------------------------------------------------------
FROM mcr.microsoft.com/vscode/devcontainers/dotnetcore:0-${DOTNET_VARIANT}
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
COPY --from=builder /root/.pulumi/bin/pulumi /pulumi/bin/pulumi
COPY --from=builder /root/.pulumi/bin/*-dotnet* /pulumi/bin/
ENV PATH "/pulumi/bin:${PATH}"
and I control the process with this .devcontainer/devcontainer.json:
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.203.0/containers/alpine
{
"name": "C# (.NET)",
"build": {
"dockerfile": "Dockerfile",
"args": {
"DOTNET_VARIANT": "3.1",
"PULUMI_VERSION": "latest",
"INSTALL_NODE": "true",
"NODE_VERSION": "lts/*"
}
},
"features": {
"azure-cli": "latest"
},
// Set *default* container specific settings.json values on container create.
"settings": {},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-dotnettools.csharp"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
// Replace when using a ptrace-based debugger like C++, Go, and Rust
// "runArgs": [ "--init", "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
"runArgs": [
"--init"
],
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
be aware that the Rebuild will take a while and that you probably have to reload the devcontainer once it indicates success in the GitHub Codespaces: Details.
After that pulumi login and e.g. pulumi new azure-csharp should work on the container.
You can spin up a codespace, and configure the devcontainer from within the codespace.
I did it just now,
Access the Command Palette (Shift + Command + P / Ctrl + Shift + P), then >start typing "dev container". Select Codespaces: Add Development Container >Configuration Files....
just follow this guide
from within following this guide - https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces
I was inspired by the builder container approach for DOTNET mentioned in this thread, and here is how I added pulumi to my GO codespace dockerfile.
Dockerfile
ARG GO_VARIANT="1"
ARG PULUMI_VERSION=latest
FROM debian:11-slim AS builder
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get install -y \
curl \
build-essential \
git
RUN if [ "$PULUMI_VERSION" = "latest" ]; then \
curl -fsSL https://get.pulumi.com/ | bash; \
else \
curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION ; \
fi
FROM mcr.microsoft.com/vscode/devcontainers/go:0-${GO_VARIANT}
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
COPY --from=builder /root/.pulumi/bin/pulumi /pulumi/bin/pulumi
COPY --from=builder /root/.pulumi/bin/*-go* /pulumi/bin/
ENV PATH "/pulumi/bin:${PATH}"
ENV GOOS "linux"
ENV GOARCH "amd64"
Snippit of code from devcontainer.json
"args": {
... //redacted for clarity
"GO_VARIANT": "1.18",
}
)
I can login with azure, pulumi and pulumi up is also working.
Full example here
https://github.com/DevOpsJava/solution-using-secret
I fixed an issue with pulumi up, which turned out to be a resource problem regarding memory. Switched codespace from 2 to 4 cores, which also doubled the memory to 8GB.

Unable to install ansible-awx Ubuntu 18.04

I am trying to install AWX on Ubuntu 18.04 and i am getting the Error.
I have checked out the latest version of awx from github and tried running the install using
ansible-playbook -i inventory install.yml -vvvv
TASK [local_docker : Start the containers] ************************************************************************************************************************************************************************
task path: /temp/awx/installer/roles/local_docker/tasks/compose.yml:25
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/cloud/docker/docker_service.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: sateesh
<localhost> EXEC /bin/sh -c 'echo ~sateesh && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/sateesh/.ansible/tmp/ansible-tmp-1555964996.64-166348838404173 `" && echo ansible-tmp-1555964996.64-166348838404173="` echo /home/sateesh/.ansible/tmp/ansible-tmp-1555964996.64-166348838404173 `" ) && sleep 0'
<localhost> PUT /home/sateesh/.ansible/tmp/ansible-local-18120SkKEmm/tmpaVUC61 TO /home/sateesh/.ansible/tmp/ansible-tmp-1555964996.64-166348838404173/docker_service.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/sateesh/.ansible/tmp/ansible-tmp-1555964996.64-166348838404173/ /home/sateesh/.ansible/tmp/ansible-tmp-1555964996.64-166348838404173/docker_service.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/env python /home/sateesh/.ansible/tmp/ansible-tmp-1555964996.64-166348838404173/docker_service.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/sateesh/.ansible/tmp/ansible-tmp-1555964996.64-166348838404173/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
File "/tmp/ansible_oWaqla/ansible_module_docker_service.py", line 745, in cmd_up
timeout=self.timeout)
File "/usr/local/lib/python2.7/dist-packages/compose/project.py", line 559, in up
'Encountered errors while bringing up the project.'
fatal: [localhost]: FAILED! => {
"changed": false,
"errors": [],
"invocation": {
"module_args": {
"api_version": null,
"build": false,
"cacert_path": null,
"cert_path": null,
"debug": false,
"definition": null,
"dependencies": true,
"docker_host": null,
"files": null,
"filter_logger": false,
"hostname_check": false,
"key_path": null,
"nocache": false,
"project_name": null,
"project_src": "/tmp/awxcompose",
"pull": false,
"recreate": "smart",
"remove_images": null,
"remove_orphans": false,
"remove_volumes": false,
"restarted": false,
"scale": null,
"services": null,
"ssl_version": null,
"state": "present",
"stopped": false,
"timeout": 10,
"tls": null,
"tls_hostname": null,
"tls_verify": null
}
},
"module_stderr": "Creating awx_web ... \r\n\r\u001b[1B",
"module_stdout": "",
"msg": "Error starting project unknown cause"
}
to retry, use: --limit #/temp/awx/installer/install.retry
PLAY RECAP ********************************************************************************************************************************************************************************************************
localhost : ok=8 changed=0 unreachable=0 failed=1
Not sure why it is failing.
I have the following versions of Ansible , pip & Docker
ansible 2.5.4
python version = 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]
Docker version 18.03.1-ce, build 9ee9f40
pip 19.0.3
Thanks
Sateesh
I've tried your solution and ran into the same issue.
My problem was that my host was running apache2, so the port 80 was already taken. After stopping and removing apache2, the build went through.
Thanks.
I've been following this question from the start as I did encounter the exact same message you did. I didn't have a possible solution to your question until now.
I just managed to install the latest version of AWX on my Ubuntu server running 18.04. What I've done to solve my issue (and I've tried this many times before) was:
Getting the latest AWX version from github
Edit the inventory file located in awx/installer keeping the path to postgres_data_dir the same as before
Use a command to kill all my running docker conatiners:
docker container kill | docker container ls $(awk '{print $1}')
Note!: I don't have any containers running except those used for AWX
Removing all containers on my system:
docker container rm <container>
Note!: Again, I don't have any containers except those used for AWX
I've used the TAB key to let bash suggest the container names
Used the ansible playbook for AWX:
ansible-playbook -i inventory install.yml
And thats it! This time I upgraded to the latest version of AWX. In my case, I wanted to update to the latest version. I don't know if you were updating or installing it "for the first time". But this is how I managed to do it, so maybe it works for you as well.
Good luck solving your issue if you haven't already.
P.S. Make sure project_src is not /tmp/awxcompose. This wil cause some issues I learned. It'll work, but if you reboot Ubuntu, AWX will run into a problem: See this link

Installing docker-compose using coreos ignition

I know how to install using cloud-config. But since this is a first-boot only task, I would instead like to install it using ignition.
Here is my attempted configuration (that doesn't work):
"systemd": {
"units": [{
"name": "install-docker-compose.service",
"contents": "[Unit]\nDescription=Install docker-compose\nConditionPathExists=!/opt/bin/docker-compose\n[Service]\nType=oneshot\nRemainAfterExit=yes\nExecStart=/usr/bin/mkdir -p /opt/bin/\nExecStart=/usr/bin/curl --create-dirs -o /opt/bin/docker-compose -sL \"https://github.com/docker/compose/releases/download/1.9.0/docker-compose-linux-x86_64\"\nExecStart=/usr/bin/chmod +x /opt/bin/docker-compose"
}]
}