forked from apache/airflow-site
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kamil Breguła
committed
Oct 9, 2019
1 parent
5d1d3f4
commit 5683a03
Showing
5 changed files
with
196 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |