Skip to content

Commit

Permalink
Add Dockerfile for the vale plugin.
Browse files Browse the repository at this point in the history
See eclipse-che/che#15856

Signed-off-by: Eric Williams <ericwill@redhat.com>
  • Loading branch information
ericwill committed Feb 5, 2020
1 parent 44cafe7 commit 0272b2d
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/build-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#
# Copyright (c) 2020 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#

name: Build and push container

on:
push:
branches:
- '0.9.0'

jobs:
build:
env:
IMAGE_NAME: quay.io/eclipse/che-sidecar-vale

runs-on: ubuntu-latest

steps:

- name: Clone source code
uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Docker build
run: |
echo "Building image ${IMAGE_NAME}"
docker build -t ${IMAGE_NAME} .
- name: Docker publish
run: |
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" quay.io
GIT_BRANCH=$(echo "${GITHUB_REF}" | cut -d / -f 3)
echo "GIT_BRANCH is ${GIT_BRANCH} and GITHUB_REF is ${GITHUB_REF}"
GIT_TAG="latest"
if [[ "$GIT_BRANCH" != "master" ]]; then
GIT_TAG=${GIT_BRANCH}
fi
# Publish with tag name
echo "Publishing image ${IMAGE_NAME}:${GIT_TAG}"
docker tag "${IMAGE_NAME}" "${IMAGE_NAME}:${GIT_TAG}"
docker push "${IMAGE_NAME}:${GIT_TAG}"
# and with specific sha-1
echo "Publishing image ${IMAGE_NAME}:${GIT_TAG}-${SHORT_SHA1}"
SHORT_SHA1=$(git rev-parse --short HEAD)
docker tag "${IMAGE_NAME}" "${IMAGE_NAME}:${GIT_TAG}-${SHORT_SHA1}"
docker push "${IMAGE_NAME}:${GIT_TAG}-${SHORT_SHA1}"
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

30 changes: 30 additions & 0 deletions .github/pr-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Copyright (c) 2020 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#

name: PR check

on:
pull_request:

jobs:
build:

runs-on: ubuntu-latest

steps:

- name: Clone source code
uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Docker build
run: |
echo "Building image..."
docker build .
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2020 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation

FROM alpine:3.11.3

ENV HOME=/home/theia
# 1.7.1 has a bug in the packaged executable, v2.0.0 is still in beta -- thus we are using 1.7.0
ENV VALE_VERSION=1.7.0

RUN mkdir /projects ${HOME} && \
# Change permissions to let any arbitrary user
for f in "${HOME}" "/etc/passwd" "/projects"; do \
echo "Changing permissions on ${f}" && chgrp -R 0 ${f} && \
chmod -R g+rwX ${f}; \
done && \
wget -qO- https://github.com/errata-ai/vale/releases/download/v${VALE_VERSION}/vale_${VALE_VERSION}_Linux_64-bit.tar.gz | tar xvz -C /usr/local/bin && \
chmod +x /usr/local/bin/vale && \
# Future word lists or config files can go here
mkdir ${HOME}/vale

ADD etc/entrypoint.sh entrypoint.sh

# Default vale.ini is needed
ADD etc/vale.ini ${HOME}

ENTRYPOINT [ "/entrypoint.sh" ]
CMD ${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}
29 changes: 29 additions & 0 deletions etc/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh
#
# Copyright (c) 2020 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#

set -e

export USER_ID=$(id -u)
export GROUP_ID=$(id -g)

if ! whoami >/dev/null 2>&1; then
echo "${USER_NAME:-user}:x:${USER_ID}:0:${USER_NAME:-user} user:${HOME}:/bin/sh" >> /etc/passwd
fi

# Grant access to projects volume in case of non root user with sudo rights
if [ "${USER_ID}" -ne 0 ] && command -v sudo >/dev/null 2>&1 && sudo -n true > /dev/null 2>&1; then
sudo chown "${USER_ID}:${GROUP_ID}" /projects
fi

exec "$@"

41 changes: 41 additions & 0 deletions etc/vale.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (c) 2020 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation


# Example Vale config file (`.vale.ini` or `_vale.ini`)

# Core settings
#
# This path has to match the same path in the Dockerfile
StylesPath = /home/theia/vale

# The minimum alert level to display (suggestion, warning, or error).
#
# CI builds will only fail on error-level alerts.
MinAlertLevel = warning

# The "formats" section allows you to associate an "unknown" format
# with one of Vale's supported formats.
[formats]
mdx = md

# Global settings (applied to every syntax)
[*]
# List of styles to load
BasedOnStyles = write-good, Joblint
# Style.Rule = {YES, NO} to enable or disable a specific rule
vale.Editorializing = YES
# You can also change the level associated with a rule
vale.Hedging = error

# Syntax-specific settings
# These overwrite any conflicting global settings
[*.{md,txt}]
vale.Editorializing = NO

0 comments on commit 0272b2d

Please sign in to comment.