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

Add Dockerfile #72

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Add Dockerfile #72

wants to merge 2 commits into from

Conversation

S-S-X
Copy link
Owner

@S-S-X S-S-X commented Feb 8, 2022

To build switch to directory where Dockerfile is and run docker build:

docker build -t mineunit .

To run temporary container mounting your mods in read only mode to run tests

docker run -it --rm --mount type=bind,source=$HOME/.minetest/mods,target=/home/mineunit,readonly mineunit

Adjust $HOME/.minetest/mods as needed, this is host directory for mods.

Possibly closes #71

@S-S-X S-S-X added enhancement New feature or request WIP Work in progress labels Feb 8, 2022
@SwissalpS SwissalpS mentioned this pull request Feb 9, 2022
@S-S-X
Copy link
Owner Author

S-S-X commented Feb 18, 2022

Now there's directory for core libs but there's no git installed by default so it is not possible to use Mineunit lib downloader feature directly, probably also wont be adding git for this image.

Instead of that probably including some preinstalled core libs to keep it lightweight, --fetch-core wont work but libraries can still be included either by mounting default library path or by changing path with --core-root.

@S-S-X
Copy link
Owner Author

S-S-X commented Mar 20, 2022

Here's also Dockerfile.local I've used to build from Mineunit source directory.

  1. Place Dockerfile.local with following contents to local Mineunit source directory.
  2. docker build -t mineunit-dev -f Dockerfile.local .
  3. docker run -it --rm --mount type=bind,source=$HOME/.minetest/mods,target=/home/mineunit,readonly mineunit-dev

Instead of installing Mineunit from Luarocks it will build directly from source directory therefore including latest / local changes to Docker image.

FROM alpine:latest as build
USER root
ENV USER=root
RUN apk add --no-cache build-base git lua-dev luarocks5.1 lua5.1-sec
RUN luarocks-5.1 install luasocket
RUN luarocks-5.1 install luacov
RUN luarocks-5.1 install busted 2.0.0-1

COPY . /build/mineunit
RUN cd /build/mineunit && luarocks-5.1 make

# Mineunit base
FROM alpine:latest
COPY --from=build /usr/local /usr/local
RUN adduser -D mineunit
RUN mkdir /usr/local/share/lua/5.1/mineunit/core
RUN chown mineunit /usr/local/share/lua/5.1/mineunit/core
RUN apk add --no-cache lua5.1

USER mineunit
WORKDIR /home/mineunit
#ENTRYPOINT ["mineunit"]
ENTRYPOINT ["sh", "-l"]

@S-S-X
Copy link
Owner Author

S-S-X commented May 29, 2022

Tested latest with GitHub actions using slightly modified image (includes git) here: https://github.com/S-S-X/mineunit-test
Seems to work fine and probably as a next step I'm going to integrate this with https://github.com/marketplace/actions/mineunit-runner

This should allow simplest resolution for broken luarocks package manager which currently causes most GitHub Mineunit workflows actions to fail.

DockerHub image is ssxx/mineunit:latest this will probably include git (which makes image a lot larger).
I've planned to release another version without git and maybe including multiple engine core library versions with full docker image.

@S-S-X
Copy link
Owner Author

S-S-X commented May 18, 2023

Pushed latest to https://hub.docker.com/r/mineunit/mineunit with custom built luassert that includes mentioned patch, seems to work without issues. (see: mt-mods/mineunit-actions#12)

For command line exec: docker run --rm -it --mount 'type=bind,source=./,target=/home/mineunit/mod' --entrypoint /bin/sh mineunit/mineunit:latest -lc "cd mod; mineunit"

For bash script:
placed in ~/bin/mineunit to allow calling mineunit like if it was actually installed but run in container and allow access only to current directory.

#!/bin/bash
cmd=("cd" "mod;" "mineunit" "${@}")
docker run --rm -it \
        --mount 'type=bind,source=./,target=/home/mineunit/mod' \
        --entrypoint /bin/sh mineunit/mineunit:latest \
        -lc "${cmd[*]}"

@S-S-X S-S-X marked this pull request as draft May 29, 2023 20:58
@S-S-X S-S-X added the in-latest-docker Included with latest docker images, might not yet be available elsewhere label Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request in-latest-docker Included with latest docker images, might not yet be available elsewhere WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hello World trouble
1 participant