<commit_before>#!/bin/bash

# Copyright 2017 Google Inc. All rights reserved.
#
# Licensed 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

# go-build.sh builds the Go application in the current work directory and
# generates a Dockerfile in that same directory.

set -e

workspace="$(pwd -P)"

if [[ -z "${GO_VERSION}" || -z "${BASE_DIGEST}" || -z "${BUILD_TAG}" ]]; then
    echo "Missing env variable(s): GO_VERSION='${GO_VERSION}', BASE_DIGEST='${BASE_DIGEST}', BUILD_TAG='${BUILD_TAG}'."
    exit 1
fi

export PATH=/usr/local/go/bin:"${PATH}"
export GOPATH="${workspace}"/_gopath

# Move application files into a temporary staging directory, dependencies excluded.
staging=$(mktemp -d staging.XXXX)
find . -mindepth 1 -maxdepth 1 ! -name "${staging}" ! -name "$(basename $GOPATH)" -exec mv {} "${staging}"/ \;

# Create a bin/ directory containing all the binaries needed in the final image.
mkdir bin
cd "${staging}"
go build -o "${workspace}"/bin/app -tags appenginevm

# Move application files into app subdirectory.
cd "${workspace}"
mv "${staging}" "${workspace}"/app

# Copy zoneinfo directory into workspace in order to be placed into final image.
cp -p -R /usr/share/zoneinfo "${workspace}"/zoneinfo

# Generate application Dockerfile.
cat > Dockerfile <<EOF
FROM gcr.io/distroless/base@${BASE_DIGEST}

LABEL build_tag="${BUILD_TAG}"
LABEL go_version="${GO_VERSION}"

COPY bin/ /usr/local/bin/
COPY app/ /app/
COPY zoneinfo/ /usr/share/zoneinfo/

WORKDIR /app
ENTRYPOINT ["/usr/local/bin/app"]
EOF<commit_msg>runtime-builder: remove copying of tzdata files (#114)<commit_after>#!/bin/bash

# Copyright 2017 Google Inc. All rights reserved.
#
# Licensed 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

# go-build.sh builds the Go application in the current work directory and
# generates a Dockerfile in that same directory.

set -e

workspace="$(pwd -P)"

if [[ -z "${GO_VERSION}" || -z "${BASE_DIGEST}" || -z "${BUILD_TAG}" ]]; then
    echo "Missing env variable(s): GO_VERSION='${GO_VERSION}', BASE_DIGEST='${BASE_DIGEST}', BUILD_TAG='${BUILD_TAG}'."
    exit 1
fi

export PATH=/usr/local/go/bin:"${PATH}"
export GOPATH="${workspace}"/_gopath

# Move application files into a temporary staging directory, dependencies excluded.
staging=$(mktemp -d staging.XXXX)
find . -mindepth 1 -maxdepth 1 ! -name "${staging}" ! -name "$(basename $GOPATH)" -exec mv {} "${staging}"/ \;

# Create a bin/ directory containing all the binaries needed in the final image.
mkdir bin
cd "${staging}"
go build -o "${workspace}"/bin/app -tags appenginevm

# Move application files into app subdirectory.
cd "${workspace}"
mv "${staging}" "${workspace}"/app

# Generate application Dockerfile.
cat > Dockerfile <<EOF
FROM gcr.io/distroless/base@${BASE_DIGEST}

LABEL build_tag="${BUILD_TAG}"
LABEL go_version="${GO_VERSION}"

COPY bin/ /usr/local/bin/
COPY app/ /app/

WORKDIR /app
ENTRYPOINT ["/usr/local/bin/app"]
EOF
{'fraction_non_alphanumeric': 0.13111798042246264, 'fraction_numerical': 0.006439979392065945, 'mean_word_length': 4.507801418439716, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3191995', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1154, 'n_words': 452}