I have the following docker file (at the bottom). I am using another image to grab a precompiled library (utilities) and copying it into the route of a new image. I then need to symlink that directory into my node_modules directory. This works fine, I have 3 places where I prove the issue.
Check for the existence of the original root directory /utilities. This works, I can see the files
Then I create the symlink: ln -sf ...
I think check to see the contents at the location of the symlink. This works, I can see the files.
I go on to create the rest of the image
At the end I again list out the files, and now I get
ls: /usr/src/app/node_modules/#boiler/utilities: No such file or directory
It's like the symlink doesn't persist. If I run the container with shell: docker run -it --entrypoint=sh backend:latest and create the symlink it works.
Any thoughts as to where my symlink is going?
FROM utilities-setup:latest as build
FROM node:8.5.0-alpine
COPY --from=build /utilities /utilities
RUN ls -l /utilities <-- 1. THIS WORKS, FILES EXIST
#setup directories
RUN mkdir -p /usr/src/app/node_modules/#boiler/
WORKDIR /usr/src/app
#create symlink to the utilities module into the boiler module
RUN ln -sf /utilities /usr/src/app/node_modules/#boiler/
RUN ls /usr/src/app/node_modules/#boiler/utilities <-- 2. THIS WORKS, FILES EXIST
#copy the content of the backend to the current direcotry
COPY . .
RUN yarn install
RUN ls /usr/src/app/node_modules/#boiler/utilities <-- 3. THIS FAILS, NO MODULE
RUN ["chmod", "+x", "./scripts/prod.sh"]
EXPOSE 8080
ENTRYPOINT ["/usr/src/app/scripts/prod.sh"]
[see comment] I clocked the problem.
What was happening was the yarn install was recreating the node_modules directory, so you have to create the symlink after all other modules are installed. Makes sense I suppose, but I thought it would just write to the directory if it already existed
Related
My go application directory structure is like this:
/app
go.mod
go.sum
main.go
When I build the app I usually cd into that directory and build.
cd app
go build
I wonder if I can build without cd in to app directory.
When I go go build /app, it prints go: go.mod file not found in current directory or any parent directory; see 'go help modules'.
See https://golang.org/ref/mod#commands-outside :
go build needs to be run from a module directory.
The simplest way is to cd into your module directory (cd /app) to run your go build command.
(there probably is some way to create a phony local go.mod file, and reference your /app module from there, but I wasn't able to devise a hack to do this)
Go now can change directory before build with the help of flag -C:
go build -C app
"The go subcommands now accept -C to change directory to before performing the command"
Source: https://tip.golang.org/doc/go1.20
(You don't need to run cd .. after this command. Shell stays in the same directory)
I'm pretty sure to build you will need to be in the app directory.
As a workaround if you are just wanting to be on the command line in a different directory and want to run the build with one command you can just chain the cd and go build commands together like this:
cd app; go build ; cd ..
This is the same amount of typing but could be in your command history just a couple presses of the up arrow away.
Note this is for bash or similar UNIX style shell. If using Windows cmd then I think it would be something like this (Not tested as I don’t have readily available access to a Windows machine right now):
cd app & go build & cd ..
I build an image from a base image. In the Dockerfile of the base image I run a command ONBUILD COPY . /workspace. When I build my image from this base image then it copy all the files from current directory to the /workspace directory of the result image.
Then I run mvn clean install from the Dockerfile with an error: cannot find symbol. The problem is that all the .java files that has long path names are not copied from current directory to the /workspace directory and so the error.
I tried to activate long pathns in Local Computer Policy, I also checked it in the registry, but it does't helped. I tried to run CMD as Administrator and then also tried to build from Git Bash command line, none fixed the problem.
Does anyone knows what could be the problem and how to resolve it?
I'm looking to run the main.launch stored in vehicle/launch/ from this github page
https://github.com/aureliopuebla/vehicle
I am very new at using ROS and have been learning, however I can't seem to be able to build these files.
If I try to use catkin_make on the parent folder it says that there is no existing 'src' folder.
If I go into the /vehicle folder there is a 'src' folder, but if I try to run catkin_make there, then it says that I have to run it at the root of the workspace. Which has me a bit stumped.
I have also tried to just run 'cmake ..', then 'make', and then 'sudo make install' in the /vehicle folder, but that just fills the /vehicle folder with copies of the other folders in the parent folder.
The reason why I want to build these packages is to be able to run the 'main.launch' file inside the '/vehicle/launch' folder with roslaunch, but it keeps saying that it can't find the other packages, no matter what I do.
Ready to clear up any questions. Thanks for the help.
the CMakeLists.txt in the folder is the top-level CMakeLists. So You need to make this src folder yourself.
Just do the following:
$ mkdir -p vehicle_ws && cd vehicle_ws
$ git clone https://github.com/aureliopuebla/vehicle.git
$ mv vehicle src
$ catkin_make
This way it should work. Just leave out mkdir -p vehicle_ws, if you already created a workspace and instead just cd into it.
I have a simple Dockerfile that I am trying to build and run my Go REST API server.
My Dockerfile so far is:
FROM golang:latest
RUN mkdir /app
ADD . /app/
WORKDIR /app
RUN go build -o main .
CMD ["/app/main"]
When I run docker-compose up I get this error:
main.go:12:2: cannot find package "github.com/bradfitz/gomemcache/memcache" in any of:
I am using godeps and my vendor folder has all the libraries vendored, why isn't the build working in this case?
Do I have to tell it to look in the vendor folder?
The vendor directory does not function as expected if your source code lies outside of GOPATH (see https://github.com/golang/go/issues/14566). In the current golang:latest Docker image, GOPATH is set to /go so the simplest solution would be to copy your code into a subdirectory of /go/src and build from there.
Is it possible to make rpmbuild to preserve symlinks on packaging?
The current behavior is to create copies of files, which I would like to avoid.
Sure it supports symlinks. But you actually have to package symlink and not copy the contents to the buildroot. Example spec packaging a symlink to /bin directory called /newbin
Name: test
Version: 1.0
Release: 1%{?dist}
Summary: nothing
License: GPLv2
Source0: nothing
%description
%install
rm -rf %{buildroot}
mkdir %{buildroot}
ln -sf /bin %{buildroot}/newbin
%files
/newbin
You'll also need nothing file in your SOURCES directory to succesfully build rpm out of this. Tested with rpm 4.9.1.2
I know this Q is old, but here's how I do it.
In the %install section, simply touch the file that will be the symlink.
touch %{buildroot}[path to your file]
In the %files section, you specify it as a %ghost file:
%ghost [path to symlink file]
By doing this, it'll be listed as part of the package's files and will also be automatically removed when the package is uninstalled.
Finally, create the symlink in the %post section:
ln -sf [file to link to] [symlink]
I don't think so. I've used the post-install script set up symlinks in my packages.