diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..fecf2fbf79e --- /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 00000000000..fda4dce9552 --- /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 ${HUGOHOME}/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 79d459056f1..51da6c0f2bb 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 d5e8b7cb569..c2099bc8c89 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 00000000000..a8d48c9bbcd --- /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} [] + +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