This is an automated email from the ASF dual-hosted git repository.

kamilbregula pushed a commit to branch pre-commit-minimal
in repository https://gitbox.apache.org/repos/asf/airflow-site.git

commit a9adf28bff5dc42ba84088de867193fffdb35cbc
Author: Kamil Breguła <[email protected]>
AuthorDate: Wed Oct 9 20:37:23 2019 +0200

    Add Travis CI + Docker integration
---
 .travis.yml                  |  36 ++++++++++++++
 Dockerfile                   |  47 ++++++++++++++++++
 landing-pages/src/index.js   |   4 --
 landing-pages/webpack.dev.js |   1 +
 site.sh                      | 112 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 196 insertions(+), 4 deletions(-)

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..fecf2fb
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,36 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+---
+dist: xenial
+language: python
+
+python: "3.6"
+stages:
+  - pre-test
+  - test
+services:
+  - docker
+install:
+  - ./site.sh build-image
+  - ./site.sh install-node-deps
+jobs:
+  include:
+    - stage: lint-js
+      script: ./site.sh lint-js
+    - stage: build
+      script: ./site.sh build-site
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..379485d
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,47 @@
+FROM debian:stretch-slim
+
+SHELL ["/bin/bash", "-o", "pipefail", "-e", "-u", "-x", "-c"]
+
+ENV DEBIAN_FRONTEND=noninteractive \
+    LANGUAGE=C.UTF-8 \
+    LANG=C.UTF-8 \
+    LC_ALL=C.UTF-8 \
+    LC_CTYPE=C.UTF-8 \
+    LC_MESSAGES=C.UTF-8
+
+RUN apt-get update \
+    && apt-get install -y --no-install-recommends \
+        curl \
+        gosu \
+        gnupg2 \
+        ca-certificates \
+        git \
+    && apt-get autoremove -yqq --purge \
+    && apt-get clean \
+    && rm -rf /var/lib/apt/lists/*
+
+RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \
+    && apt-get update \
+    && apt-get install -y --no-install-recommends \
+        nodejs \
+    && apt-get autoremove -yqq --purge \
+    && apt-get clean \
+    && rm -rf /var/lib/apt/lists/*
+
+RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
+    && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee 
/etc/apt/sources.list.d/yarn.list \
+    && apt-get update \
+    && apt-get install -y --no-install-recommends yarn \
+    && apt-get autoremove -yqq --purge \
+    && apt-get clean \
+    && rm -rf /var/lib/apt/lists/*
+
+RUN HUGOHOME="$(mktemp -d)" \
+    && export HUGOHOME \
+    && curl -sL 
https://github.com/gohugoio/hugo/releases/download/v0.58.3/hugo_extended_0.58.3_Linux-64bit.tar.gz
 > "${HUGOHOME}/hugo.tar.gz" \
+    && tar -xzvf /tmp/hugo.tar.gz hugo \
+    && mv hugo /usr/local/bin/hugo \
+    && chmod +x /usr/local/bin/hugo \
+    && rm -r "${HUGOHOME}"
+
+WORKDIR /opt/site/
diff --git a/landing-pages/src/index.js b/landing-pages/src/index.js
index 79d4590..51da6c0 100644
--- a/landing-pages/src/index.js
+++ b/landing-pages/src/index.js
@@ -16,7 +16,3 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
-console.log("🦊 Hello! Edit me in src/index.js");
-export const foo = () => console.log("foo");
-foo()
diff --git a/landing-pages/webpack.dev.js b/landing-pages/webpack.dev.js
index d5e8b7c..c2099bc 100644
--- a/landing-pages/webpack.dev.js
+++ b/landing-pages/webpack.dev.js
@@ -33,6 +33,7 @@ module.exports = merge(common, {
   },
 
   devServer: {
+    host: '0.0.0.0',
     port: process.env.PORT || 3000,
     contentBase: path.join(process.cwd(), "./dist"),
     watchContentBase: true,
diff --git a/site.sh b/site.sh
new file mode 100755
index 0000000..a8d48c9
--- /dev/null
+++ b/site.sh
@@ -0,0 +1,112 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -euox pipefail
+
+MY_DIR="$(cd "$(dirname "$0")" && pwd)"
+pushd "${MY_DIR}" &>/dev/null || exit 1
+
+function check_image_exists {
+    if docker images | tail -n +2 | cut -d " " -f 1 | sort | uniq | grep "$1" 
> /dev/null; then
+        return 0
+    fi
+    return 1
+}
+
+function usage {
+cat << EOF
+usage: ${0} <command> [<args>]
+
+These are  ${0} commands used in various situations:
+
+    build-image        Build a Docker image with a  environment
+    install-node-deps  Download all the Node dependencies
+    preview            Starts the web server
+    build-site         Builds a website
+    lint-js            Lint all javascript files
+    shell              Start shell.
+    help               Display usage
+
+Unrecognized commands are run as programs in the container.
+
+For example, if you want to display a list of files, you
+can execute the following command:
+
+    $0 ls
+
+EOF
+}
+
+function ensure_image_exists {
+    if ! check_image_exists "airflow-site"; then
+        echo "Image not exists."
+        build_image
+    fi
+}
+
+function ensure_node_module_exists {
+    if [[ ! -d landing-pages/node_modules/ ]] ; then
+        echo "Missing node depedencies. Start installation."
+        start_container bash -c "cd landing-pages/ && yarn install"
+        echo "Dependencies installed"
+    fi
+}
+
+function build_image {
+    echo "Start building image"
+    docker build -t airflow-site .
+    echo "End building image"
+}
+
+function start_container {
+    ensure_image_exists
+
+    docker run -ti \
+        -v "$(pwd):/opt/site/" \
+        -p 1313:1313 \
+        -p 3000:3000 \
+        airflow-site "$@"
+}
+
+if [[ "$#" -ge 1 ]] ; then
+    if [[ "$1" == "build-image" ]] ; then
+        build_image
+    elif [[ "$1" == "install-node-deps" ]] ; then
+        start_container bash -c "cd landing-pages/ && yarn install"
+    elif [[ "$1" == "preview" ]]; then
+        ensure_node_module_exists
+        start_container bash -c "cd landing-pages/site && npm run preview"
+    elif [[ "$1" == "build-site" ]]; then
+        ensure_node_module_exists
+        start_container bash -c "cd landing-pages/site && npm run build"
+    elif [[ "$1" == "lint-js" ]]; then
+        ensure_node_module_exists
+        start_container bash -c "cd landing-pages/site && npm run lint"
+    elif [[ "$1" == "shell" ]]; then
+        start_container "bash"
+    elif [[ "$1" == "help" ]]; then
+        usage
+    else
+        start_container "$@"
+    fi
+else
+    usage
+fi
+
+popd &>/dev/null || exit 1

Reply via email to