I am trying to connect my Hyperledger Fabric network with my backend in Heroku.
I did all the connections as the examples suggest. This is how my code looks like:
my code
When I deploy to Heroku I get the following error:
[NetworkConfig101.js]: NetworkConfig101 - problem reading the PEM file :: Error: ENOENT: no such file or directory
My .pem files are in the same folder as my configuration file. folders
Using a path from working dir. For example, your tree structure dir:
.
├── app.js
└── artifacts
├── crypto-config
│ ├── ca.crt
│ └── key.pem
└── network-config.yaml
In network-config.yaml, you should use path:
path: ./artifacts/crypto-config/ca.crt
Another way is using absolute path.
path: /data/app/artifacts/crypto-config/ca.crt
Related
How can I use COPY in Dockerfile to copy folder of which name starts with a dot?
FROM confluentinc/cp-kafka-connect:6.0.0
# does not work
COPY ./aws/ /home/appuser/.aws
EXPOSE 8083
Directory structure:
/MyFolder
├── .aws
│ └── credentials
└── Dockerfile
COPY ./aws [DESTINATION] is "COPY, from the current directory './', the directory named 'aws' to the [DESTINATION]".
COPY ./.aws [DESTINATION] will COPY the hidden directory '.aws' from the current directory './' to [DESTINATION].
COPY ./.aws/ /home/appuser/.aws will result in /home/appuser/.aws/credentials existing in the built image.
Tip: [DESTINATION] is created by COPY if it doesn't already exist.
Note: if the directory is ignored in a .dockerignore then the COPY will not work.
Note: should never COPY credentials in an image if you intend on sharing the image rather bind-mount the credentials during the containers runtime i.e. docker run --rm -it -v ./.aws/credentials:/home/appuser/.aws/credentials:ro myimage
I'm trying to build a Dockerfile to copy a file to container, I'm using Windows 10. This is my Dockerfile
FROM openjdk:8
COPY /target/myfile.java /
And I'm getting the error:
failed to solve with frontend dockerfile.v0: failed to build LLB: failed to compute cache key: "/target/myfile.java" not found: not found
I already tried //target//myfile.java, \\target\\myfile.java, \target\myfile.java, target/myfile.java, target\myfile.java but none of them worked.
If I put the myfile.java on the same directory of Dockerfile and use COPY myfile.java / works without problem. So the problem is to copy a file inside a folder. Any suggestion?
I tried your Dockerfile locally and it built fine with the following directory structure:
Project
│ Dockerfile
│
└───target
│ │ myfile.java
I built it from the 'Project' directory with the following command:
docker build . -t java-test
I could only reproduce the error when the Docker server couldn't find the 'myfile.java', i.e. using the following directory structure:
Project
│ Dockerfile
│
└───target
│ └───target
│ └───myfile.java
So your dockerfile looks fine, just make sure you build it from the right directory with the correct build context and the file is stored in the correct place locally
I succesfully deployed a Laravel website onto a web server by cloning it into a directory at the same level as public_html (called laravel) and creating a symlink to the laravel/public directory into public_html, with this command:
ln -s laravel/public public_html
This works great.
Now I want to have a "test" version of the site for development, and I wanted to do the same.
I cloned my project in a "laravel_dev" directory, same level as public_html and laravel directories.
I created a public_html/dev directory.
Now, I want to create a symlink of 'laravel_dev/public' into 'public_hmtl/dev' and here is where I am having trouble.
If I do
ln -s laravel_dev/public public_html/dev
It creates a file (not a directory) called public inside public_html/dev.
I tried making the target go to laravel/public/dev, with the same result.
I double checked that laravel_dev/public directory exists and it is not empty.
I also tried removing the dev directory inside laravel/public/dev, and the result there is that it creates a file called dev inside laravel/public but it is not a directory.
To clarify, my directory tree is something like this:
www
|___public_html(1)/dev
|___laravel/public(1*)/dev
|___laravel_dev/public
I am positioned in www directory when I am executing the mentioned commands
The (number) indicates symlink and the * indicates the "physical" directory. Using this notation here is what I want to acomplish:
www
|___public_html(1)/dev(2)
|___laravel/public(1*)/dev(2)
|___laravel_dev/public(2*)
You should just make link in the physical directory.
mkdir laravel{,_dev}
ln -s laravel public_html
ln -s ../laravel_dev laravel/dev
It gives me following directory/files tree
[Alex#Normandy so]$ tree
.
├── laravel
│ └── dev -> ../laravel_dev
├── laravel_dev
└── public_html -> laravel
Simple test:
[Alex#Normandy so]$ echo "test dev" > laravel_dev/test
[Alex#Normandy so]$ cat public_html/dev/test
test dev
Note that there might be also problem with your webserver.
Usually we use "strapi start" to start strapi.
I'm hosting it on AWS ubuntu:
tried "start strapi &" to run it in background. However, once the terminal is closed, we can't access the strapi console anymore.
I got script not found: server.js error when using #user1872384's solution.
So, here is the correct way to run strapi in background mode.
NODE_ENV=production pm2 start --name APP_NAME npm -- start
This will just tell pm2 to use npm start command and let npm do the which script to run part.
Hope it helps someone.
To run the strapi in development mode, use the following pm2 command from your project folder.
pm2 start npm --name my-project -- run develop
and
pm2 list
to view the status
We also can start with pm2 by type
pm2 start "yarn develop"
Need to use pm2:
To Start:
npm install pm2 -g
NODE_ENV=production pm2 start server.js --name api
To list all process:
pm2 list
┌──────────┬────┬─────────┬──────┬───────┬────────┬─────────┬────────┬─────┬────────────┬────────┬──────────┐
│ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
├──────────┼────┼─────────┼──────┼───────┼────────┼─────────┼────────┼─────┼────────────┼────────┼──────────┤
│ api │ 0 │ 0.1.0 │ fork │ 21817 │ online │ 0 │ 2m │ 0% │ 108.0 MB │ ubuntu │ disabled │
└──────────┴────┴─────────┴──────┴───────┴────────┴─────────┴────────┴─────┴────────────┴────────┴──────────┘
To Stop, use the id:
pm2 stop 0
First
npm install pm2 -g
add server.js to root of your project and write below line:
const strapi = require('strapi');
strapi().start();
save then
pm2 start server.js
The best way is to use pm2 and its ecosystem.config.js file.
Firstly, install pm2 by:
npm i -g pm2#latest
In ecosystem.config.js, add the following code:
module.exports = {
apps: [
{
name: 'give-your-app-a-name',
script: 'npm',
args: 'start',
watch: true, // automatically restart the server for file changes
max_memory_restart: '450M',
env: {
NODE_ENV: 'production',
},
},
{
name: 'give-your-another-app-a-name',
script: 'npm',
args: 'start',
env: {
NODE_ENV: 'production',
},
},
],
}
Finally on your server do:
pm2 start ecosystem.config.js
That's it.
Here's the official page about starting Strapi with PM2.
Starting with strapi command
By default there is two important commands.
yarn develop to start your project in development mode.
yarn start to start your app for production.
You can also start your process manager using the yarn start or develop command.
pm2 start npm --name my-app -- run develop
pm2 start npm --name my-app -- run develop
I'm starting with MongoDB and taking four courses. All of them use different versions of mongodb, python, nodejs, asp.net, mean stack, etc. The structure of my desirable workspace:
courses
├─ mongodb_basic
│ ├─ hello_world-2.7.py
│ └─ data
│ └─ db
├─ python-3.6_mongodb
│ ├─ getting_started.py
│ └─ data
│ └─ db
├─ dotnet_and_mongodb
│ ├─ (project files)
│ └─ data
│ └─ db
├─ mongodb_node
│ ├─ (project files)
│ └─ data
│ └─ db
└─ mean_intro
└─ (project files)
I want to keep my Windows 10 system clean using Docker without installing all the stuff on the host and stuck in the first course, don't know how to:
link containers
python/pymongo <-> mongodb
aspnet <-> mongodb
... <-> mongodb
map data\folders
start/stop linked containers with one command (desirable)
I'd like to keep a workspace on the host (external HDD) in order to work on different computers (three W10 PCs).
Google results have many tuts (containerize, docker-compose, etc.) and don't know where to start.
I think it might be possible to do what you are trying to do using docker-compose and defining the dockerfiles correctly. So if you are wondering where to start, I would suggest getting acquainted with the dockerfiles and docker-compose.
To answer your question:
linking containers:
that can be done using docker-compose. Specify the container services you want to use in a compose file like the one specified here.
NOTE: the volumes: declaration is where you would specify your workspace folder structure for the containers to access.
map folder/data: Again I would check out the link mentioned above. In their dockerfile they use the ADD command to add the current directory of the container into the path of the /code directory. This was included as a volume: in the compose file. What does that mean? Well whatever you change in the host workspace, should show up in the root directory of the container.
start/stop with one command: you should be able to create,start or stop all the services or a specific service using one of the docker-compose up, docker-compose start or docker-compose stop
commands.
For your application you might even be able to get away with defining your workspace as volumes in all of the dockerfiles and then building them with a script. Or you can use some kind of orchestration service like Kubernetes as well but that might be overkill.
Hope this is helpful.