Skip to content

Commit

Permalink
Merge pull request #1 from cytopia/release-0.1
Browse files Browse the repository at this point in the history
Initial release
  • Loading branch information
cytopia authored Jun 13, 2019
2 parents 3674059 + 479a6eb commit a02f39a
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---

###
### Enable sudo (required for docker service)
###
sudo: required


###
### Language
###
language: python


###
### Add services
###
services:
- docker


###
### Build Matrix
###
env:
matrix:
- VERSION=latest


###
### Install requirements
###
install:
# Get newer docker version
- while ! sudo apt-get update; do sleep 1; done
- while ! sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce; do sleep 1; done
- docker version


###
### Check generation changes, build and test
###
before_script:
- while ! make build TAG=${VERSION}; do sleep 1; done
- while ! make test TAG=${VERSION}; do sleep 1; done


###
### Push to Dockerhub
###
script:
# Push to docker hub on success
- if [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then
while ! make login USER="${DOCKER_USERNAME}" PASS="${DOCKER_PASSWORD}"; do sleep 1; done;
if [ -n "${TRAVIS_TAG}" ]; then
while ! make push TAG="${VERSION}-${TRAVIS_TAG}"; do sleep 1; done;
elif [ "${TRAVIS_BRANCH}" == "master" ]; then
while ! make push TAG=${VERSION}; do sleep 1; done;
elif [[ ${TRAVIS_BRANCH} =~ ^(release-[.0-9]+)$ ]]; then
while ! make push TAG="${VERSION}-${TRAVIS_BRANCH}"; do sleep 1; done;
else
echo "Skipping branch ${TRAVIS_BRANCH}";
fi
else
echo "Skipping push on PR";
fi
53 changes: 53 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
FROM alpine:latest as builder

RUN set -x \
&& apk add --no-cache \
nodejs-current \
npm

ARG VERSION=latest
RUN set -x \
&& if [ ${VERSION} = "latest" ]; then \
npm install global --production --remove-dev eslint; \
else \
npm install global --production --remove-dev eslint@^${VERSION}.0.0; \
fi
# Remove unecessary files
RUN set -x \
&& find /node_modules -type d -iname 'test' -prune -exec rm -rf '{}' \; \
&& find /node_modules -type d -iname 'tests' -prune -exec rm -rf '{}' \; \
&& find /node_modules -type d -iname 'testing' -prune -exec rm -rf '{}' \; \
&& find /node_modules -type d -iname '.bin' -prune -exec rm -rf '{}' \; \
\
&& find /node_modules -type f -iname '.*' -exec rm {} \; \
&& find /node_modules -type f -iname 'LICENSE*' -exec rm {} \; \
&& find /node_modules -type f -iname 'Makefile*' -exec rm {} \; \
&& find /node_modules -type f -iname '*.bnf' -exec rm {} \; \
&& find /node_modules -type f -iname '*.css' -exec rm {} \; \
&& find /node_modules -type f -iname '*.def' -exec rm {} \; \
&& find /node_modules -type f -iname '*.flow' -exec rm {} \; \
&& find /node_modules -type f -iname '*.html' -exec rm {} \; \
&& find /node_modules -type f -iname '*.info' -exec rm {} \; \
&& find /node_modules -type f -iname '*.jst' -exec rm {} \; \
&& find /node_modules -type f -iname '*.lock' -exec rm {} \; \
&& find /node_modules -type f -iname '*.map' -exec rm {} \; \
&& find /node_modules -type f -iname '*.markdown' -exec rm {} \; \
&& find /node_modules -type f -iname '*.md' -exec rm {} \; \
&& find /node_modules -type f -iname '*.mjs' -exec rm {} \; \
&& find /node_modules -type f -iname '*.mli' -exec rm {} \; \
&& find /node_modules -type f -iname '*.png' -exec rm {} \; \
&& find /node_modules -type f -iname '*.ts' -exec rm {} \; \
&& find /node_modules -type f -iname '*.yml' -exec rm {} \;

FROM alpine:latest
LABEL \
maintainer="cytopia <cytopia@everythingcli.org>" \
repo="https://github.com/cytopia/docker-eslint"
COPY --from=builder /node_modules/ /node_modules/
RUN set -x \
&& apk add --no-cache nodejs-current \
&& ln -sf /node_modules/eslint/bin/eslint.js /usr/bin/eslint

WORKDIR /data
ENTRYPOINT ["eslint"]
CMD ["--help"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 cytopia <https://github.com/cytopia>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.PHONY: build rebuild test tag pull login push enter

DIR = .
FILE = Dockerfile
IMAGE = cytopia/eslint
TAG = latest

build:
docker build --build-arg VERSION=$(TAG) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR)

rebuild: pull
docker build --no-cache --build-arg VERSION=$(TAG) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR)

test:
@if [ "$(TAG)" = "latest" ]; then \
echo "Fetching latest version from GitHub"; \
LATEST="$$( \
curl -L -sS https://github.com/eslint/eslint/releases/latest/ \
| tac | tac \
| grep -Eo "eslint/eslint/releases/tag/v[.0-9]+" \
| head -1 \
| sed 's/.*v//g' \
)"; \
echo "Testing for latest: $${LATEST}"; \
docker run --rm $(IMAGE) --version | grep -E "^v?$${LATEST}$$"; \
else \
echo "Testing for tag: $(TAG)"; \
docker run --rm $(IMAGE) --version | grep -E "^v?$(TAG)$$"; \
fi

tag:
docker tag $(IMAGE) $(IMAGE):$(TAG)

pull:
@grep -E '^\s*FROM' Dockerfile \
| sed -e 's/^FROM//g' -e 's/[[:space:]]*as[[:space:]]*.*$$//g' \
| xargs -n1 docker pull;

login:
yes | docker login --username $(USER) --password $(PASS)

push:
@$(MAKE) tag TAG=$(TAG)
docker push $(IMAGE):$(TAG)

enter:
docker run --rm --name $(subst /,-,$(IMAGE)) -it --entrypoint=/bin/sh $(ARG) $(IMAGE):$(TAG)

0 comments on commit a02f39a

Please sign in to comment.