Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make docker run locally #3680

Closed

Conversation

TracerDS
Copy link
Contributor

This PR localizes Docker. It no longer copies mtasa repo but local copy of the mta.

@TracerDS TracerDS changed the title Localize docker Make docker run locally Aug 26, 2024
Comment on lines +24 to +32
RUN mkdir -p Client Server Shared utils vendor

COPY Client Client
COPY Server Server
COPY Shared Shared
COPY utils utils
COPY vendor vendor
COPY ./* .

Copy link
Member

@TheNormalnij TheNormalnij Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use -v parameter in docker run to mount these folders into a container

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would it work?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should mount mta repository (or an empty folder) to /build folder in a container. docker-entrypoint.sh runs inside this folder.

Comment on lines -24 to -28
# So, first make a shallow clone of the repository if it not exists
umask 000
if [ ! -f ./premake5.lua ]; then
git clone --depth=1 https://github.com/multitheftauto/mtasa-blue.git .
fi
Copy link
Member

@TheNormalnij TheNormalnij Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Nothing is wrong here. This line allows you to build MTA without cloning the MTA repository.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line actually clones the entire repo all the time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't. Check your command line and current folder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does. Docker pulls mta repo from github if that line is saved. Without it, it runs only local changes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I tested it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too. It didnt accept local copy unless I remove that line.
If you try to build mta then you already have necessary files in your filesystem.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cd <mta sa repo here>
docker build -t mtasabuilder:latest .
docker run --rm -v ./:/build mtasabuilder:latest

Does it work?

Copy link
Contributor Author

@TracerDS TracerDS Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"volume name is too short, names should be at least two alphanumeric characters."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker run --rm -v <full path to repo>:/build mtasabuilder:latest

?

@TheNormalnij
Copy link
Member

It works locally now

docker build -t mtasabuilder:latest .
docker run --rm -v ./:/build mtasabuilder:latest

@botder
Copy link
Member

botder commented Oct 1, 2024

Did you ever try the steps under Building with Docker from the README?

mtasa-blue/README.md

Lines 113 to 122 in 550a152

**Building with Docker**
These examples assume that your current directory is the mtasa-blue checkout directory. You should also know that `/build` is the code directory required by our Docker images inside the container. If the current directory is not a valid git repository, it instead create a (shallow) clone of the mtasa-blue repository. After compiling, you will find the resulting binaries in `./Bin`. To build the unoptimised debug build, add `-e BUILD_CONFIG=debug` to the docker run arguments.
| Architecture | Build command |
| ------------ | -------------------------------------------------------------------------------------- |
| x86_64 | ``` docker run --rm -v `pwd`:/build ghcr.io/multitheftauto/mtasa-blue-build:latest ``` |
| x86 | ``` docker run --rm -v `pwd`:/build ghcr.io/multitheftauto/mtasa-blue-build:i386 ``` |
| arm | ``` docker run --rm -v `pwd`:/build ghcr.io/multitheftauto/mtasa-blue-build:armhf ``` |
| arm64 | ``` docker run --rm -v `pwd`:/build ghcr.io/multitheftauto/mtasa-blue-build:arm64 ``` |

@TracerDS
Copy link
Contributor Author

TracerDS commented Oct 2, 2024

Did you ever try the steps under Building with Docker from the README?

mtasa-blue/README.md

Lines 113 to 122 in 550a152

**Building with Docker**
These examples assume that your current directory is the mtasa-blue checkout directory. You should also know that `/build` is the code directory required by our Docker images inside the container. If the current directory is not a valid git repository, it instead create a (shallow) clone of the mtasa-blue repository. After compiling, you will find the resulting binaries in `./Bin`. To build the unoptimised debug build, add `-e BUILD_CONFIG=debug` to the docker run arguments.
| Architecture | Build command |
| ------------ | -------------------------------------------------------------------------------------- |
| x86_64 | ``` docker run --rm -v `pwd`:/build ghcr.io/multitheftauto/mtasa-blue-build:latest ``` |
| x86 | ``` docker run --rm -v `pwd`:/build ghcr.io/multitheftauto/mtasa-blue-build:i386 ``` |
| arm | ``` docker run --rm -v `pwd`:/build ghcr.io/multitheftauto/mtasa-blue-build:armhf ``` |
| arm64 | ``` docker run --rm -v `pwd`:/build ghcr.io/multitheftauto/mtasa-blue-build:arm64 ``` |

I did, but no matter what I do I always get a copy of the github repo instead of my local one.

@botder
Copy link
Member

botder commented Oct 2, 2024

I did, but no matter what I do I always get a copy of the github repo instead of my local one.

Alright, but did you try using --entrypoint /bin/bash to look around and see if you properly mounted the files in /build ?

@TheNormalnij
Copy link
Member

"volume name is too short, names should be at least two alphanumeric characters."

Do you use powershell in windows?

@TracerDS
Copy link
Contributor Author

TracerDS commented Oct 2, 2024

Alright, but did you try using --entrypoint /bin/bash to look around and see if you properly mounted the files in /build ?

Didn't try that exact method but when lsing the root dir, no directories were copied.

Do you use powershell in windows?

Nope

@botder
Copy link
Member

botder commented Oct 2, 2024

Alright, but did you try using --entrypoint /bin/bash to look around and see if you properly mounted the files in /build ?

Didn't try that exact method but when lsing the root dir, no directories were copied.

You're supposed to mount your local directory into the Docker container, and by poking around within a /bin/bash shell, you can see if your mount is actually working. If it's not there, then obviously the docker-entrypoint.sh script is going to clone the repository everytime.

@TheNormalnij
Copy link
Member

Invalid / a system issue

@TracerDS TracerDS deleted the 260824_Improve-docker branch October 18, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants