mirror of
https://github.com/minetest/minetest.git
synced 2024-11-22 23:53:44 +01:00
Docker image workflow (publish on ghcr.io
) (#14230)
This commit is contained in:
parent
24cc33e704
commit
5a27c05b6a
89
.github/workflows/docker_image.yml
vendored
Normal file
89
.github/workflows/docker_image.yml
vendored
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
---
|
||||||
|
name: docker_image
|
||||||
|
|
||||||
|
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images
|
||||||
|
# https://docs.docker.com/build/ci/github-actions/multi-platform
|
||||||
|
# https://github.com/opencontainers/image-spec/blob/main/annotations.md
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
# Publish semver tags as releases.
|
||||||
|
tags: [ "*.*.*" ]
|
||||||
|
pull_request:
|
||||||
|
# Build docker image on pull requests. (but do not publish)
|
||||||
|
paths:
|
||||||
|
- 'lib/**.[ch]'
|
||||||
|
- 'lib/**.cpp'
|
||||||
|
- 'src/**.[ch]'
|
||||||
|
- 'src/**.cpp'
|
||||||
|
- '**/CMakeLists.txt'
|
||||||
|
- 'cmake/Modules/**'
|
||||||
|
- 'util/ci/**'
|
||||||
|
- 'misc/irrlichtmt_tag.txt'
|
||||||
|
- 'Dockerfile'
|
||||||
|
- '.dockerignore'
|
||||||
|
- '.github/workflows/docker_image.yml'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
# github.repository as <account>/<repo>
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Docker buildx
|
||||||
|
uses: docker/setup-buildx-action@v3.0.0
|
||||||
|
|
||||||
|
# Login against the Docker registry except on PR
|
||||||
|
# https://github.com/docker/login-action
|
||||||
|
- name: Log into registry ${{ env.REGISTRY }}
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v3.0.0
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
# Extract metadata (tags, labels) for Docker
|
||||||
|
# https://github.com/docker/metadata-action
|
||||||
|
- name: Extract Docker metadata
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5.5.0
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.title=Minetest
|
||||||
|
org.opencontainers.image.vendor=Minetest
|
||||||
|
org.opencontainers.image.licenses=LGPL-2.1-only
|
||||||
|
|
||||||
|
# Build and push Docker image
|
||||||
|
# https://github.com/docker/build-push-action
|
||||||
|
# No arm support for now. Require cross-compilation support in Dockerfile to not use QEMU.
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v5.1.0
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
load: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
|
- name: Test Docker Image
|
||||||
|
run: |
|
||||||
|
docker run --rm $(cut -d, -f1 <<<"$DOCKER_METADATA_OUTPUT_TAGS") minetestserver --version
|
||||||
|
shell: bash
|
10
.github/workflows/linux.yml
vendored
10
.github/workflows/linux.yml
vendored
@ -151,13 +151,3 @@ jobs:
|
|||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: |
|
||||||
./bin/minetestserver --run-unittests
|
./bin/minetestserver --run-unittests
|
||||||
|
|
||||||
docker:
|
|
||||||
name: "Docker image"
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Build docker image
|
|
||||||
run: |
|
|
||||||
docker build . -t minetest:latest
|
|
||||||
docker run --rm minetest:latest /usr/local/bin/minetestserver --version
|
|
||||||
|
@ -127,9 +127,7 @@ Docker
|
|||||||
------
|
------
|
||||||
|
|
||||||
- [Developing minetestserver with Docker](doc/developing/docker.md)
|
- [Developing minetestserver with Docker](doc/developing/docker.md)
|
||||||
|
- [Running a server with Docker](doc/docker_server.md)
|
||||||
We provide a Dockerfile that can be used to build the server.
|
|
||||||
|
|
||||||
|
|
||||||
Version scheme
|
Version scheme
|
||||||
--------------
|
--------------
|
||||||
|
46
doc/docker_server.md
Normal file
46
doc/docker_server.md
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# Docker Server
|
||||||
|
|
||||||
|
We provide Minetest server Docker images using the GitHub container registry.
|
||||||
|
|
||||||
|
Images are built on each commit and available using the following tag scheme:
|
||||||
|
|
||||||
|
* `ghcr.io/minetest/minetest:master` (latest build)
|
||||||
|
* `ghcr.io/minetest/minetest:<tag>` (specific Git tag)
|
||||||
|
* `ghcr.io/minetest/minetest:latest` (latest Git tag, which is the stable release)
|
||||||
|
|
||||||
|
See [here](https://github.com/minetest/minetest/pkgs/container/minetest) for all available tags.
|
||||||
|
|
||||||
|
For a quick test you can easily run:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker run ghcr.io/minetest/minetest:master
|
||||||
|
```
|
||||||
|
|
||||||
|
To use it in a production environment, you should use volumes bound to the Docker host to persist data and modify the configuration:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker create -v /home/minetest/data/:/var/lib/minetest/ -v /home/minetest/conf/:/etc/minetest/ ghcr.io/minetest/minetest:master
|
||||||
|
```
|
||||||
|
|
||||||
|
You may also want to use [Docker Compose](https://docs.docker.com/compose):
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
version: "2"
|
||||||
|
services:
|
||||||
|
minetest_server:
|
||||||
|
image: ghcr.io/minetest/minetest:master
|
||||||
|
restart: always
|
||||||
|
networks:
|
||||||
|
- default
|
||||||
|
volumes:
|
||||||
|
- /home/minetest/data/:/var/lib/minetest/
|
||||||
|
- /home/minetest/conf/:/etc/minetest/
|
||||||
|
ports:
|
||||||
|
- "30000:30000/udp"
|
||||||
|
- "127.0.0.1:30000:30000/tcp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Data will be written to `/home/minetest/data` on the host, and configuration will be read from `/home/minetest/conf/minetest.conf`.
|
||||||
|
|
||||||
|
**Note:** If you don't understand the previous commands please read the [official Docker documentation](https://docs.docker.com) before use.
|
Loading…
Reference in New Issue
Block a user