0

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:\n\tno field package.preload['economyManager']\n\tno cached module 'economyManager', \nstack traceback:\n\t[G]: in function 'require'\n\t/nakama/data/modules/src/main.lua:2: in main chunk\n\t[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

1
  • Show us tree structure of your directory. Commented Apr 28, 2022 at 18:10

2 Answers 2

1

Your command seems to be right, just add a trailing / to the destination docker image's path.

For example,

COPY *.lua /nakama/data/modules/ 
Sign up to request clarification or add additional context in comments.

5 Comments

Tryied that and I still get the same error. FROM heroiclabs/nakama:3.11.0 COPY *.lua /nakama/data/modules/ COPY database/*.lua /nakama/data/modules/ COPY managers/*.lua /nakama/data/modules/ COPY modules/*.lua /nakama/data/modules/ COPY local.yml /nakama/data The files seems to not get copied to the modules directory, only the main.lua one that its at the root of the directory.
Try to put ./database/*.lua instead of database/*.lua
Still the same error, COPY ./database/*.lua /nakama/data/modules/ and COPY ./database/*.lua /nakama/data/modules
Could you share the tree structure of your directory and check from where you are running the docker build cmd
Added directory structure and a better and cleaner error, thx for all the help!
0

The error was on the docker-compose file, I was double mounting a volume and that was causing errors on the whole COPY operation.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.