forked from GoogleCloudPlatform/marketplace-vm-imagebuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
69 lines (60 loc) · 2.55 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright 2018 Google LLC. 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
FROM marketplace.gcr.io/google/debian11
ENV PACKER_VERSION 1.8.3
ENV PACKER_SHA256 0587f7815ed79589cd9c2b754c82115731c8d0b8fd3b746fe40055d969facba5
ENV PACKER_BINARY /bin/packer
ENV CHEF_DIR /chef
ENV PACKER_DIR /packer/templates
ENV TESTS_DIR /tests
ENV KEY_FILE_PATH /service-account.json
# Installs packages
RUN set -eux \
&& apt-get update \
&& apt-get install -y \
curl \
gnupg2 \
jq \
openssh-client \
python3 \
unzip
# Installs gcloud
RUN set -eux \
&& export CLOUD_SDK_REPO="cloud-sdk-stretch" \
&& echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list \
&& curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - \
&& apt-get update -y && apt-get install google-cloud-sdk -y
# Installs Packer
RUN set -eux \
# Downloads binary
&& curl -O "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip" \
# Verifies checksum
&& echo "${PACKER_SHA256} packer_${PACKER_VERSION}_linux_amd64.zip" | sha256sum -c \
# Unzips binary
&& unzip "packer_${PACKER_VERSION}_linux_amd64.zip" \
&& rm "packer_${PACKER_VERSION}_linux_amd64.zip" \
# Moves binary
&& mv packer ${PACKER_BINARY} \
&& chmod +x ${PACKER_BINARY} \
# Downloads source code
&& curl -L -o packer.tar.gz "https://github.com/hashicorp/packer/archive/v${PACKER_VERSION}.tar.gz" \
&& mkdir -p /usr/local/src/packer \
&& tar -xzf packer.tar.gz -C /usr/local/src/packer --strip-components=1 \
&& rm packer.tar.gz
# Downloads licenses
RUN set -eux \
&& mkdir -p /usr/share/imagebuilder \
&& curl -o /usr/share/imagebuilder/packer.LICENSE "https://raw.githubusercontent.com/hashicorp/packer/v${PACKER_VERSION}/LICENSE" \
&& curl -o /usr/share/imagebuilder/chef-solo.LICENSE "https://raw.githubusercontent.com/chef/chef/master/LICENSE"
COPY scripts /imagebuilder
ENTRYPOINT ["/imagebuilder/build-vm-image.sh"]