Skip to content

Commit 28fce8a

Browse files
authored
Add dev stage to docker image (luanti-org#13573)
1 parent e0948f4 commit 28fce8a

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG DOCKER_IMAGE=alpine:3.16
2-
FROM $DOCKER_IMAGE AS builder
2+
FROM $DOCKER_IMAGE AS dev
33

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

38+
FROM dev as builder
39+
3840
COPY .git /usr/src/minetest/.git
3941
COPY CMakeLists.txt /usr/src/minetest/CMakeLists.txt
4042
COPY README.md /usr/src/minetest/README.md

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ Compiling
131131

132132
Docker
133133
------
134+
135+
- [Developing minetestserver with Docker](doc/developing/docker.md)
136+
134137
We provide Minetest server Docker images using the GitLab mirror registry.
135138

136139
Images are built on each commit and available using the following tag scheme:

doc/developing/docker.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Developing minetestserver with Docker
2+
3+
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.
4+
5+
## Creating an image
6+
7+
The first step is to create a development image of minetestserver:
8+
```bash
9+
docker buildx build --target dev -t minetest-dev:0 .
10+
```
11+
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.
12+
13+
## Opening a new container
14+
15+
Once an image has been created, a new container can be opened, with the source code mounted into it:
16+
```bash
17+
docker run -it \
18+
--mount type=bind,source=/home/bob/minetest,target=/minetest \
19+
minetest-dev:0
20+
```
21+
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.
22+
23+
### For VSCode users
24+
25+
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 commit comments

Comments
 (0)