Rearrange directories and CI a little

This commit is contained in:
Neale Pickett 2020-09-17 18:56:40 -06:00
parent 0a60a649a1
commit c45773f6f7
11 changed files with 126 additions and 64 deletions

View File

@ -1,12 +0,0 @@
name: Mothd Docker build
on: [push]
jobs:
build-mothd:
name: Build mothd
runs-on: ubuntu-latest
steps:
- name: Retrieve code
uses: actions/checkout@v1
- name: Build mothd
run: docker build .

View File

@ -1,4 +1,4 @@
name: Publish Container image name: Publish
on: on:
release: release:
types: [published] types: [published]
@ -10,18 +10,45 @@ jobs:
steps: steps:
- name: Retrieve code - name: Retrieve code
uses: actions/checkout@v1 uses: actions/checkout@v1
- name: Push to GitHub Packages
- name: Push moth to GitHub Packages
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
target: moth
file: build/package/Containerfile
registry: docker.pkg.github.com registry: docker.pkg.github.com
repository: dirtbags/moth/moth repository: dirtbags/moth/moth
tag_with_ref: true tag_with_ref: true
- name: Push to Docker Hub
- name: Push moth-devel to GitHub Packages
uses: docker/build-push-action@v2
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
target: moth-devel
file: build/package/Containerfile
registry: docker.pkg.github.com
repository: dirtbags/moth/moth-devel
tag_with_ref: true
- name: Push moth to Docker Hub
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
username: neale username: neale
password: ${{ secrets.DOCKER_TOKEN }} password: ${{ secrets.DOCKER_TOKEN }}
registry: dirtbags/moth target: moth
file: build/packages/Containerfile
repository: dirtbags/moth
tag_with_ref: true
- name: Push moth-devel to Docker Hub
uses: docker/build-push-action@v2
with:
username: neale
password: ${{ secrets.DOCKER_TOKEN }}
target: moth-devel
file: build/packages/Containerfile
repository: dirtbags/moth-devel
tag_with_ref: true tag_with_ref: true

16
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: Tests
on: [push]
jobs:
test-mothd:
name: Test mothd
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.13
- name: Retrieve code
uses: actions/checkout@v1
- name: Test
run: go test ./...

3
.gitignore vendored
View File

@ -4,8 +4,5 @@
*.o *.o
.idea .idea
./bin/ ./bin/
build/
cache/
target/
puzzles puzzles
__debug_bin __debug_bin

View File

@ -4,20 +4,29 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [4.0.0] - Unreleased ## [v4.0.0] - Unreleased
### Added
- New `transpile` command to replace some functionality of devel server
### Changed ### Changed
- Major rewrite/refactor of `mothd` - Major rewrite/refactor of `mothd`
- There are now providers for State, Puzzles, and Theme. Sqlite, Redis, or S3 should fit in easily. - Clear separation of roles: State, Puzzles, and Theme
- Sqlite, Redis, or S3 should fit in easily now
- Will allow "dynamic" puzzles now, we just need a flag to enable it
- Server no longer provides unlocked content - Server no longer provides unlocked content
- Puzzle URLs are now just `/content/${cat}/${points}/` - Puzzle URLs are now just `/content/${cat}/${points}/`
- `state/until` is now `state/hours` and can specify multiple begin/end hours - Changes to `state` directory
- `state/disabled` is now `state/enabled` - Most files now have a bit of (English) documentation at the beginning
- Mothball structure has changed substantially - `state/until` is now `state/hours` and can specify multiple begin/end hours
- `state/disabled` is now `state/enabled`
- Mothball structure has changed
- Mothballs no longer contain `map.txt` - Mothballs no longer contain `map.txt`
- Mothballs no longer obfuscate content paths
- Clients now expect unlocked puzzles to just be `map[string][]int` - Clients now expect unlocked puzzles to just be `map[string][]int`
- New `/state` API endpoint
- Provides *all* server state: event log, team mapping, messages, configuration
### Added
- New `transpile` CLI command
- Provides `mothball` action to create mothballs
- Lets you test a few development server things, if you want
### Deprecated ### Deprecated

View File

@ -1,19 +0,0 @@
FROM golang:1.13 AS builder
COPY go.* /src/
COPY pkg /src/pkg/
COPY cmd /src/cmd/
COPY theme /target/theme/
COPY example-puzzles /target/puzzles/
COPY LICENSE.md /target/
WORKDIR /src/
RUN CGO_ENABLED=0 GOOS=linux go install -i -a -ldflags '-extldflags "-static"' ./...
RUN mkdir -p /target/bin
RUN cp /go/bin/* /target/bin/
FROM builder AS tester
RUN go test ./...
FROM scratch
COPY --from=builder /target /
ENTRYPOINT [ "/bin/mothd" ]

View File

@ -1,8 +1,8 @@
Dirtbags Monarch Of The Hill Server Dirtbags Monarch Of The Hill Server
===================== =====================
![](https://github.com/dirtbags/moth/workflows/Mothd%20Docker%20build/badge.svg?branch=master) ![Build badge](https://github.com/dirtbags/moth/workflows/Mothd%20Docker%20build/badge.svg?branch=master)
![](https://github.com/dirtbags/moth/workflows/moth-devel%20Docker%20build/badge.svg?branch=master) ![Go report card](https://goreportcard.com/badge/github.com/dirtbags/moth)
Monarch Of The Hill (MOTH) is a puzzle server. Monarch Of The Hill (MOTH) is a puzzle server.
We (the authors) have used it for instructional and contest events called We (the authors) have used it for instructional and contest events called

View File

@ -1 +0,0 @@
3.5.1

View File

@ -1,14 +0,0 @@
#! /bin/sh
set -e
read version < VERSION
cd $(dirname $0)
for img in moth moth-devel; do
echo "==== $img"
sudo docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --tag dirtbags/$img --tag dirtbags/$img:$version -f Dockerfile.$img .
[ "$1" = "-push" ] && docker push dirtbags/$img:$version && docker push dirtbags/$img:latest
done
exit 0

View File

@ -0,0 +1,37 @@
FROM golang:1.13 AS builder
COPY go.* /src/
COPY pkg /src/pkg/
COPY cmd /src/cmd/
COPY theme /target/theme/
COPY example-puzzles /target/puzzles/
COPY LICENSE.md /target/
WORKDIR /src/
RUN CGO_ENABLED=0 GOOS=linux go install -i -a -ldflags '-extldflags "-static"' ./...
# I can't put these in /target/bin: doing so would cause the devel server to overwrite Ubuntu's /bin
RUN mkdir -p /target/bin/
RUN cp /go/bin/* /target/
##########
FROM builder AS tester
RUN go test ./...
##########
FROM scratch AS moth
COPY --from=builder /target /
ENTRYPOINT [ "/mothd" ]
##########
FROM ubuntu AS moth-devel
RUN apt-get -y update && apt-get -y install \
build-essential \
bsdgames \
figlet toilet \
python3 \
python3-pil \
lua5.3
COPY --from=builder /bin/* /
CMD [ "/mothd", "-puzzles", "/puzzles" ]

22
build/package/build.sh Executable file
View File

@ -0,0 +1,22 @@
#! /bin/sh
set -e
cd $(dirname $0)/../..
PODMAN=$(command -v podman || echo docker)
VERSION=$(cat CHANGELOG.md | awk -F '[][]' '/^## \[/ {print $2; exit}')
for target in moth moth-devel; do
tag=dirtbags/$target:$VERSION
echo "==== Building $tag"
$PODMAN build \
--build-arg http_proxy --build-arg https_proxy --build-arg no_proxy \
--tag dirtbags/$target \
--tag dirtbags/$target:$VERSION \
--target $target \
-f build/package/Containerfile .
[ "$1" = "-push" ] && docker push dirtbags/$target:$VERSION && docker push dirtbags/$img:latest
done
exit 0