Starting to use Docker here.
Right now im facing an issue with my project, where I need to copy multiple files from multiple directories to the docker image on start up.
Here is my current code
FROM heroiclabs/nakama:3.11.0
COPY src/*.lua /nakama/data/modules
COPY src/database/*.lua /nakama/data/modules
COPY src/managers/*.lua /nakama/data/modules
COPY src/modules/*.lua /nakama/data/modules
COPY local.yml /nakama/data
What is happening so far is that docker copies only the main.lua file from the starting directory, it either dont copy the remaining ones or copy them with the current data structure.
How can I actually copy it in order to get the lua files from database, manages and modules into the same root directory as main.lua?
To add to this, I get this error on the Nakama console that indicates that a file searched by main.lua module its not found.
{"level":"fatal","ts":"2022-04-28T21:19:51.163Z","caller":"main.go:154","msg":"Failed initializing runtime modules","error":"/nakama/data/modules/src/main.lua:2: module economyManager not found:ntno field package.preload['economyManager']ntno cached module 'economyManager', nstack traceback:nt[G]: in function 'require'nt/nakama/data/modules/src/main.lua:2: in main chunknt[G]: ?"}
So far so good, the / at the end of each COPY line did not do the trick.
Edit:
This is the full directory structure:
src
-database
--luascripts.lua
-managers
--luascripts.lua
-modules
--luascripts.lua
-main.lua
intellisense
-nakama.lua
local.yml
dorckerfile
docker-compose.yml
This helps better illustrate the error. As you can se on the log, docker its copying src directory over to nakama/data/modules, what I aim to do is to copy ONLY the content from src, but not the src directory.
Same can be said for other directories to a lesser degree, my aim is to not carry over directory structure to the destination path
2
Answers
The error was on the docker-compose file, I was double mounting a volume and that was causing errors on the whole COPY operation.
Your command seems to be right, just add a trailing
/
to the destination docker image’s path.For example,