Skip to content

Commit

Permalink
Add dev stage to docker image (minetest#13573)
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiahWI authored and Wuzzy2 committed Jul 31, 2023
1 parent f6fa841 commit 4b0c853
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG DOCKER_IMAGE=alpine:3.16
FROM $DOCKER_IMAGE AS builder
FROM $DOCKER_IMAGE AS dev

ENV MINETEST_GAME_VERSION master
ENV IRRLICHT_VERSION master
Expand Down Expand Up @@ -35,6 +35,8 @@ RUN git clone --recursive https://github.com/jupp0r/prometheus-cpp/ && \
git clone --depth=1 https://github.com/minetest/irrlicht/ -b ${IRRLICHT_VERSION} && \
cp -r irrlicht/include /usr/include/irrlichtmt

FROM dev as builder

COPY .git /usr/src/minetest/.git
COPY CMakeLists.txt /usr/src/minetest/CMakeLists.txt
COPY README.md /usr/src/minetest/README.md
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ Compiling

Docker
------

- [Developing minetestserver with Docker](doc/developing/docker.md)

We provide Minetest server Docker images using the GitLab mirror registry.

Images are built on each commit and available using the following tag scheme:
Expand Down
25 changes: 25 additions & 0 deletions doc/developing/docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Developing minetestserver with Docker

Docker provides an easy cross-platform solution to create a development environment. The advantage of this method is that it does not require you to install any development tools and libraries on your machine besides git and docker. This is a short guide describing how to set up a development environment for minetestserver; people unfamiliar with docker may also want to refer to the [Docker Documentation](https://docs.docker.com//) which is well written.

## Creating an image

The first step is to create a development image of minetestserver:
```bash
docker buildx build --target dev -t minetest-dev:0 .
```
The `--target dev` option instructs docker to build the intermediate development image, and the `-t minetest-dev:0` option tags the image so we can refer to it by that name.

## Opening a new container

Once an image has been created, a new container can be opened, with the source code mounted into it:
```bash
docker run -it \
--mount type=bind,source=/home/bob/minetest,target=/minetest \
minetest-dev:0
```
The `-it` runs the container interactively and puts you into a terminal in the container. The source and target of the bind mount should point to the directory on the host machine, and the directory in the container, respectively.

### For VSCode users

If you install the development container extension from the VSCode marketplace, you can attach VSCode to the running container, and open the source in VSCode to work with it as you would any other project. Note that extensions must be installed in the container from the extensions tab once the container has been attached if you wish to use them. For more information, see the VSCode documentation on [Developing inside a Container using Visual Studio Code Remote Development](https://code.visualstudio.com/docs/devcontainers/containers#:~:text=The%20Visual%20Studio%20Code%20Dev%20Containers%20extension%20lets,advantage%20of%20Visual%20Studio%20Code%27s%20full%20feature%20set.).

0 comments on commit 4b0c853

Please sign in to comment.