Merge branch 'master' into simplify_dockerbuild

This commit is contained in:
Vidar Holen 2018-03-20 22:31:21 -07:00 committed by GitHub
commit a5b359591c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 23 deletions

View File

@ -15,28 +15,27 @@ before_install:
script: script:
- mkdir deploy - mkdir deploy
# Windows .exe
- docker pull koalaman/winghc
- docker run --user="$UID" --rm -v "$PWD:/appdata" koalaman/winghc cuib
- for tag in $TAGS; do cp "dist/build/ShellCheck/shellcheck.exe" "deploy/shellcheck-$tag.exe"; done
- rm -rf dist || true
# Linux static executable
- docker pull koalaman/scbuilder
- docker run --user="$UID" --rm -v "$PWD:/mnt" koalaman/scbuilder
- for tag in $TAGS; do cp "shellcheck" "deploy/shellcheck-$tag.linux"; done
- ./shellcheck --version
- rm -rf dist || true
# Linux Docker image # Linux Docker image
- name="$DOCKER_BASE" - name="$DOCKER_BASE"
- DOCKER_BUILDS="$DOCKER_BUILDS $name" - DOCKER_BUILDS="$DOCKER_BUILDS $name"
- docker build -t "$name:current" . - docker build -t "$name:current" .
- docker run "$name:current" --version - docker run "$name:current" --version
# Copy static executable from docker image
- id=$(docker create "$name:current")
- docker cp "$id:/bin/shellcheck" "shellcheck"
- docker rm "$id"
- for tag in $TAGS; do cp "shellcheck" "deploy/shellcheck-$tag.linux"; done
# Linux Alpine based Docker image # Linux Alpine based Docker image
- name="$DOCKER_BASE-alpine" - name="$DOCKER_BASE-alpine"
- DOCKER_BUILDS="$DOCKER_BUILDS $name" - DOCKER_BUILDS="$DOCKER_BUILDS $name"
- sed -e 's/^FROM .*/FROM alpine:latest/' -e '/WORKDIR/d' -e '/ENTRYPOINT/d' Dockerfile > Dockerfile.alpine - sed -e '/DELETE-MARKER/,$d' Dockerfile > Dockerfile.alpine
- docker build -f Dockerfile.alpine -t "$name:current" . - docker build -f Dockerfile.alpine -t "$name:current" .
- docker run "$name:current" sh -c 'shellcheck --version' - docker run "$name:current" sh -c 'shellcheck --version'
# Windows .exe
- docker pull koalaman/winghc
- docker run --user="$UID" --rm -v "$PWD:/appdata" koalaman/winghc cuib
- for tag in $TAGS; do cp "dist/build/ShellCheck/shellcheck.exe" "deploy/shellcheck-$tag.exe"; done
- rm -rf dist || true
# Misc packaging # Misc packaging
- ./.prepare_deploy - ./.prepare_deploy

View File

@ -1,23 +1,34 @@
FROM ubuntu:16.04 AS build # Build-only image
FROM ubuntu:17.10 AS build
# Install GHC and cabal
USER root USER root
WORKDIR /opt/shellCheck WORKDIR /opt/shellCheck
COPY . . # Install OS deps
RUN apt-get update && apt-get install -y ghc cabal-install
RUN apt-get update && apt-get install -y \ # Install Haskell deps
ghc \ # (This is a separate copy/run so that source changes don't require rebuilding)
cabal-install COPY ShellCheck.cabal ./
RUN cabal update && \ RUN cabal update && cabal install --dependencies-only
cabal install --dependencies-only
# Copy source and build it
COPY LICENSE Setup.hs shellcheck.hs ./
COPY src src
RUN cabal build Paths_ShellCheck && \ RUN cabal build Paths_ShellCheck && \
ghc -optl-static -optl-pthread -idist/build/autogen --make shellcheck && \ ghc -optl-static -optl-pthread -isrc -idist/build/autogen --make shellcheck && \
strip --strip-all shellcheck strip --strip-all shellcheck
RUN mkdir -p /out/bin && \ RUN mkdir -p /out/bin && \
cp shellcheck /out/bin/ cp shellcheck /out/bin/
# Resulting Alpine image
FROM alpine:latest
LABEL maintainer="Vidar Holen <vidar@vidarholen.net>"
COPY --from=build /out /
# DELETE-MARKER (Remove everything below to keep the alpine image)
# Resulting ShellCheck image
FROM scratch FROM scratch
LABEL maintainer="Vidar Holen <vidar@vidarholen.net>" LABEL maintainer="Vidar Holen <vidar@vidarholen.net>"
WORKDIR / WORKDIR /

View File

@ -157,7 +157,19 @@ or see the [storage bucket listing](https://shellcheck.storage.googleapis.com/in
## Travis CI ## Travis CI
Travis CI now integrated ShellCheck by default, you don't need to manually install it. Travis CI has now integrated ShellCheck by default, so you don't need to manually install it.
However, if you want the _latest_ version you may have to still install it yourself:
install:
# Install latest version of shellcheck.
- wget https://storage.googleapis.com/shellcheck/shellcheck-latest.linux.x86_64.tar.xz
- tar --xz -xvf shellcheck-latest.linux.x86_64.tar.xz
- shellcheck-latest/shellcheck --version
script:
- shellcheck-latest/shellcheck *.sh
## Compiling from source ## Compiling from source