Add travis ci, linter, merge shellcheck, fix some issues (#241)

* Quote all vars, remove useless echo/sub-shell, add shebands, fail on unset vars, enable pipefail, formatting

* Add CI including linting via hadolint nad shellcheck

* Update all base images to tag 3.9

* Switch to maintainer labels

* Quote vars

* Remove commented code

* Ignore if the folder exists
This commit is contained in:
Florian Kinder 2019-05-02 17:28:20 +02:00 committed by GitHub
parent e34180ca51
commit 605ca74c0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 73 additions and 10 deletions

14
.hadolint.yaml Normal file
View File

@ -0,0 +1,14 @@
ignored:
# ignore apt version pinning
- DL3008
# ignore pip version pinning
- DL3013
# ignore apk version pinning
- DL3018
# ignore pipefail cause Balena/resin.io images do not work with it
- DL4006
# ignore false positive regex
- SC1083
- SC2086
# ignore as need for debug
- SC2005

35
.travis.yml Normal file
View File

@ -0,0 +1,35 @@
dist: xenial
sudo: required
language: bash
services:
- docker
addons:
apt:
packages:
- jq
jobs:
include:
- stage: test
env: HADOLINT=${HOME}/hadolint
install: curl -sLo ${HADOLINT} $(curl -s https://api.github.com/repos/hadolint/hadolint/releases/latest?access_token=${GITHUB_TOKEN} | jq -r '.assets | .[] | select(.name=="hadolint-Linux-x86_64") | .browser_download_url')
&& chmod 700 ${HADOLINT}
script:
- git ls-files --exclude='*Dockerfile' --ignored | xargs --max-lines=1 ${HADOLINT}
- bash -c 'shopt -s globstar; shellcheck **/*.sh'
- &build
stage: build
env: VERSION=0.17
script:
- ./build.sh $VERSION
after_success:
- if [ "$TRAVIS_BRANCH" == "master" ]; then
echo "$DOCKER_PASSWORD" | DOCKER login -u "$DOCKER_USERNAME" --password-stdin
docker push "factoriotools/docker_factorio_server:$VERSION"
fi
- <<: *build
env: VERSION=0.16
- <<: *build
env: VERSION=0.15
- <<: *build
env: VERSION=0.14

View File

@ -1,11 +1,11 @@
FROM frolvlad/alpine-glibc:alpine-3.4
FROM frolvlad/alpine-glibc:alpine-3.9
MAINTAINER https://github.com/dtandersen/docker_factorio_server
LABEL maintainer="https://github.com/dtandersen/docker_factorio_server"
ENV VERSION=0.14.23 \
SHA1=6ef84341c6fc1cf45cfdd6acc8468aaa117b9e8a
RUN mkdir /opt && \
RUN mkdir -p /opt && \
apk --no-cache add curl tini pwgen && \
curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
-o /tmp/factorio_headless_x64_$VERSION.tar.gz && \

View File

@ -30,6 +30,6 @@ fi
exec /opt/factorio/bin/x64/factorio \
--port 34197 \
--start-server-load-latest \
--server-settings $CONFIG/server-settings.json \
--server-settings "$CONFIG/server-settings.json" \
--rcon-port 27015 \
--rcon-password "$(cat "$CONFIG/rconpw")"

View File

@ -1,13 +1,13 @@
FROM frolvlad/alpine-glibc:alpine-3.6
FROM frolvlad/alpine-glibc:alpine-3.9
MAINTAINER https://github.com/dtandersen/docker_factorio_server
LABEL maintainer="https://github.com/dtandersen/docker_factorio_server"
ENV PORT=34197 \
RCON_PORT=27015 \
VERSION=0.15.40 \
SHA1=f79a975f6b8c0ee87e2fa60f7d1f7133f332c3ec
RUN mkdir /opt && \
RUN mkdir -p /opt && \
apk add --update --no-cache tini pwgen && \
apk add --update --no-cache --virtual .build-deps curl && \
curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \

View File

@ -1,6 +1,6 @@
FROM frolvlad/alpine-glibc:alpine-3.7
FROM frolvlad/alpine-glibc:alpine-3.9
MAINTAINER https://github.com/dtandersen/docker_factorio_server
LABEL maintainer="https://github.com/dtandersen/docker_factorio_server"
ARG USER=factorio
ARG GROUP=factorio

View File

@ -1,6 +1,6 @@
FROM frolvlad/alpine-glibc:alpine-3.9
MAINTAINER https://github.com/dtandersen/docker_factorio_server
LABEL maintainer="https://github.com/dtandersen/docker_factorio_server"
ARG USER=factorio
ARG GROUP=factorio

12
build.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
set -eo pipefail
if [ -z "$1" ] ; then
echo "Usage: ./build.sh \$VERSION"
else
VERSION="$1"
fi
cd "$VERSION" || exit
docker build . -t "factoriotools/docker_factorio_server:$VERSION"

2
lint.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
git ls-files --exclude='*Dockerfile' --ignored | xargs --max-lines=1 ./hadolint