Skip to content
This repository was archived by the owner on Nov 18, 2023. It is now read-only.

Commit 2fdbd0a

Browse files
committed
fix: makefile and scripts
1 parent 2ab40df commit 2fdbd0a

File tree

4 files changed

+41
-65
lines changed

4 files changed

+41
-65
lines changed

Makefile

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
TEST_MODULES = actions cmd components config constants file helper plugin-loader rdbms table-definition transform
66
HP_VERSION:=$(shell git describe --tags --abbrev=0 | tr -d '[:space:]')
77
ORA_VERSION=19.14
8+
BUILD_DATE=$(shell date +%F) # use +%FT%H:%M%z for format '2020-10-08T17:55+0100'
89
OSARCH=$(shell uname | tr "[:upper:]" "[:lower:]")
910
GOARCH=amd64
10-
BUILD_DATE=$(shell date +%F) # use +%FT%H:%M%z for format '2020-10-08T17:55+0100'
1111
LD_FLAGS:=-X github.com/relloyd/halfpipe/cmd.version=${HP_VERSION} -X github.com/relloyd/halfpipe/cmd.buildDate=${BUILD_DATE} -X github.com/relloyd/halfpipe/cmd.osArch=${OSARCH}
1212
LD_FLAGS_VERBOSE:="-v"
1313
LD_FLAGS_DEV:=-ldflags "${LD_FLAGS}"
@@ -115,12 +115,12 @@ build-linux: check-ora-vars
115115
CGO_ENABLED=1 GOOS=$(OSARCH) GOARCH=$(GOARCH) go build -v -trimpath $(LD_FLAGS_RELEASE) -buildmode=plugin -o dist/hp-odbc-plugin.so rdbms/odbc/main.go
116116

117117
###############################################################################
118-
# BUILD & INSTALL
118+
# BUILD & INSTALL NATIVE BINARIES
119119
###############################################################################
120120

121121
.PHONY: install
122122
install: build
123-
cp -p dist/hp ~/go/bin/
123+
cp -p dist/hp $$GOPATH/bin/
124124

125125
.PHONY: install-so
126126
install-so: build build-so
@@ -135,29 +135,41 @@ install-so: build build-so
135135
docker-build:
136136
scripts/docker-build.sh $(ORA_VERSION) $(HP_VERSION) relloyd/halfpipe-oracle-$(ORA_VERSION)
137137

138-
.PHONY: docker-get-files
139-
docker-get-files:
140-
$(eval RELEASE_DIR=dist/hp-linux-amd64-$(HP_VERSION)-oracle-$(ORA_VERSION))
141-
mkdir -p $(RELEASE_DIR)
142-
$(eval id=$(shell docker create relloyd/halfpipe-oracle-$(ORA_VERSION)):$(HP_VERSION)))
143-
docker cp $(id):/usr/local/bin/hp $(RELEASE_DIR)
144-
docker cp $(id):/usr/local/lib/hp-odbc-plugin.so $(RELEASE_DIR)
145-
docker cp $(id):/usr/local/lib/hp-oracle-plugin.so $(RELEASE_DIR)
146-
docker rm -v $(id)
138+
.PHONY: docker-run
139+
docker-run:
140+
mkdir -p $$HOME/.halfpipe && \
141+
docker run -ti --rm \
142+
-v $$HOME/.halfpipe:/home/dataops/.halfpipe \
143+
relloyd/halfpipe-oracle-$(ORA_VERSION):latest
147144

148145
###############################################################################
149146
# QUICKSTART
147+
#
148+
# 1. Build the core halfpipe docker image with additional tools like
149+
# AWS CLI, kubectl, k9s, less and other CLI hacks.
150+
# 2. Start the image with .aws and .halfpipe directories mounted
151+
# and AWS_PROFILE=halfpipe
152+
#
150153
###############################################################################
151154

152155
.PHONY: quickstart
153-
quickstart:
154-
$(MAKE) docker-build
155-
scripts/start-halfpipe.sh relloyd/halfpipe-oracle-$(ORA_VERSION)
156+
quickstart: docker-build
157+
scripts/start-halfpipe.sh relloyd/halfpipe-oracle-$(ORA_VERSION):latest
156158

157159
###############################################################################
158160
# RELEASES
159161
###############################################################################
160162

163+
.PHONY: docker-get-files
164+
docker-get-files:
165+
$(eval RELEASE_DIR=dist/hp-linux-amd64-$(HP_VERSION)-oracle-$(ORA_VERSION))
166+
mkdir -p $(RELEASE_DIR)
167+
$(eval id=$(shell docker create relloyd/halfpipe-oracle-$(ORA_VERSION)):$(HP_VERSION)))
168+
docker cp $(id):/usr/local/bin/hp $(RELEASE_DIR)
169+
docker cp $(id):/usr/local/lib/hp-odbc-plugin.so $(RELEASE_DIR)
170+
docker cp $(id):/usr/local/lib/hp-oracle-plugin.so $(RELEASE_DIR)
171+
docker rm -v $(id)
172+
161173
.PHONY: release
162174
release: release-darwin release-linux
163175
@echo Release complete

image/Dockerfile-quickstart

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
1-
ARG HP_VERSION
21
ARG ORA_VERSION
32

4-
FROM relloyd/halfpipe-oracle-${ORA_VERSION}-no-oci:${HP_VERSION}
3+
FROM relloyd/halfpipe-oracle-${ORA_VERSION}:latest
54

65
USER root
76

7+
# AWS CLI
8+
89
RUN apt-get update -y \
910
&& apt-get install -y curl less vim libaio1 ca-certificates unzip glibc-source groff \
1011
&& curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
1112
&& unzip awscliv2.zip \
1213
&& ./aws/install \
1314
&& rm awscliv2.zip
1415

15-
# Oracle client (use LD_LIBRARY_PATH from parent image).
16-
17-
RUN cd /tmp \
18-
&& curl -L https://download.oracle.com/otn_software/linux/instantclient/19800/instantclient-basiclite-linux.x64-19.8.0.0.0dbru.zip -o instantclient-basiclite-linux.x64-19.8.0.0.0dbru.zip \
19-
&& for i in instantclient*19.8*.zip; do unzip "$i"; done \
20-
&& rm instantclient*19.8*.zip \
21-
&& mv instantclient* /usr/lib/instantclient
22-
2316
# Kubectl
2417

25-
ARG K8S_VERSION
26-
ENV K8S_VERSION=${K8S_VERSION}
27-
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl \
18+
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \
2819
&& chmod +x ./kubectl \
2920
&& mv ./kubectl /usr/local/bin/kubectl \
3021
&& echo "alias k=kubectl" >> .bashrc
@@ -33,7 +24,7 @@ RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/${K8S_VER
3324

3425
RUN mkdir -p /usr/local/k9s \
3526
&& cd /usr/local/k9s \
36-
&& curl -L https://github.com/derailed/k9s/releases/download/0.9.2/k9s_0.9.2_Linux_x86_64.tar.gz -o k9s.tar.gz \
27+
&& curl -L https://github.com/derailed/k9s/releases/download/v0.25.18/k9s_Linux_x86_64.tar.gz -o k9s.tar.gz \
3728
&& tar xvzf k9s.tar.gz \
3829
&& rm k9s.tar.gz \
3930
&& chmod +x k9s \
@@ -42,15 +33,8 @@ RUN mkdir -p /usr/local/k9s \
4233

4334
USER dataops
4435

45-
# Set the halfpipe version so scripts can use it as a default.
46-
47-
ARG HP_VERSION
48-
ENV HP_VERSION=${HP_VERSION}
49-
5036
# Scripts
5137

52-
COPY --chown=dataops:dataops kubes/template/ /home/dataops/.template/
53-
COPY --chown=dataops:dataops kubes/create-k8s-pipe-job /home/dataops/
5438
COPY --chown=dataops:dataops configure.sh /home/dataops/
5539
COPY --chown=dataops:dataops .template-variables.env /home/dataops/
5640

oci8-docker.pc

Lines changed: 0 additions & 12 deletions
This file was deleted.

scripts/start-halfpipe.sh

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22

3-
set -e # exit after any failure
3+
set -e
44

5-
script_dir=`dirname $0`
6-
image_name=${1:?"Supply the halfpipe Docker image name as \$1"}
5+
image=${1:?"Supply the halfpipe Docker image:tag as \$1"}
6+
script_dir=$(dirname "$0")
77
default_aws_profile=halfpipe
88
default_port=8080
99

@@ -17,7 +17,7 @@ Usage: $0 [ -a <AWS profile name> ] [-p <port>]"
1717
1818
-a supplies a profile name found in '$HOME/.aws/credentials'
1919
to set AWS access keys in the container (default: ${default_aws_profile})
20-
-p port to expose for Halfpipe's micro-service used by 'hp pipe' commands
20+
-p port to expose for Halfpipe's microservice used by 'hp pipe' commands
2121
(default: $default_port)
2222
2323
EOF
@@ -40,36 +40,28 @@ if [[ -z "${aws_profile}" ]]; then # if the profile has NOT been set...
4040
aws_profile="${default_aws_profile}" # use the default.
4141
fi
4242

43-
if [[ "$kube" -eq 1 ]]; then # if we should mount ~/.kube/config...
44-
if [[ -d "$HOME/.kube" ]]; then # if the directory exists...
45-
# Get ready to mount the directory.
46-
kube_mount="-v \"$HOME/.kube\":/home/dataops/.kube"
47-
else # else there is no .kube directory...
48-
# Abort.
49-
echo "Error: \"$HOME/.kube\" directory not found and -k flag specified"
50-
usage
51-
fi
52-
fi
53-
5443
if [[ -z "$port" ]]; then # if the port has NOT been set...
5544
port=$default_port
5645
fi
5746

5847
# Create if not exists the halfpipe home dir.
48+
5949
mkdir -p ~/.halfpipe
6050

6151
# Add defaults for the first time.
52+
6253
if [[ ! -f "$HOME/.halfpipe/config.yaml" ]]; then # if there are no existing config defaults...
6354
echo "Using default config file config.yaml"
6455
cp "${script_dir}/.default-config.yaml" "$HOME/.halfpipe/config.yaml"
6556
fi
6657

6758
# Start Halfpipe container.
68-
echo "Starting ${image_name}:latest using AWS profile \"${aws_profile}\"..."
59+
60+
echo "Starting ${image}:latest using AWS profile \"${aws_profile}\"..."
6961
cmd="docker run -ti --rm \\
7062
-v ~/.halfpipe:/home/dataops/.halfpipe \\
7163
-v ~/.aws:/home/dataops/.aws \\
7264
-e AWS_PROFILE=\"${aws_profile}\" \\
7365
-p ${port}:8080 \\
74-
${image_name}:latest"
66+
${image}"
7567
eval "$cmd"

0 commit comments

Comments
 (0)