-
Notifications
You must be signed in to change notification settings - Fork 2
/
.bashrc
152 lines (138 loc) · 4.27 KB
/
.bashrc
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash -e
# This script proxies all needed tools for CICD through trusted docker containers.
# shellcheck disable=SC2046
# shellcheck disable=SC2086
set -eo pipefail
function docker_run() {
local DOCKER_WORK=${DOCKER_WORK:-"$(pwd)"}
local DOCKER_HOME=${DOCKER_HOME:-"$(pwd)"}
local DOCKER_USER=${DOCKER_USER:-"$(id -u):$(id -g)"}
local DOCKER_NETWORK=${DOCKER_NETWORK:-"services"}
local OPTS
OPTS="${OPTS} --rm"
OPTS="${OPTS} --interactive"
OPTS="${OPTS} --env DOCKER_USER=${DOCKER_USER}"
OPTS="${OPTS} --user ${DOCKER_USER}"
OPTS="${OPTS} --env DOCKER_HOME=${DOCKER_HOME}"
OPTS="${OPTS} --volume ${DOCKER_HOME}:${DOCKER_HOME}" && \
OPTS="${OPTS} --env HOME=${DOCKER_HOME}"
OPTS="${OPTS} --env DOCKER_WORK=${DOCKER_WORK}"
OPTS="${OPTS} --volume ${DOCKER_WORK}:${DOCKER_WORK}" && \
OPTS="${OPTS} --workdir ${DOCKER_WORK}"
OPTS="${OPTS} --env DOCKER_NETWORK=${DOCKER_NETWORK}"
docker network inspect "${DOCKER_NETWORK}" &> /dev/null && \
OPTS="${OPTS} --network ${DOCKER_NETWORK}"
docker run ${OPTS} "${@}"
}
function mvn() {
local DOCKER_IMAGE="maven:3.8.5-amazoncorretto-17"
docker image inspect "${DOCKER_IMAGE}" &> /dev/null ||
docker pull "${DOCKER_IMAGE}" > /dev/null
docker_run \
--env MAVEN_OPTS \
--env APP_OAUTH2_ISSUER \
--env APP_DEVICE_REST_URL \
--env APP_VEHICLE_REST_URL \
--entrypoint mvn \
"${DOCKER_IMAGE}" \
"${@}"
}
function npm() {
local DOCKER_IMAGE="node:16"
docker image inspect "${DOCKER_IMAGE}" &> /dev/null ||
docker pull "${DOCKER_IMAGE}" > /dev/null
docker_run \
--env GITLAB_TOKEN \
--entrypoint npm \
"${DOCKER_IMAGE}" \
"${@}"
}
function asciidoctor() {
local DOCKER_IMAGE="asciidoctor/docker-asciidoctor:1.3.0"
docker image inspect "${DOCKER_IMAGE}" &> /dev/null ||
docker pull "${DOCKER_IMAGE}" > /dev/null
docker_run \
--entrypoint asciidoctor \
"${DOCKER_IMAGE}" \
"${@}"
}
function asciidoctor2confluence() {
local DOCKER_IMAGE="confluencepublisher/confluence-publisher:0.16.0"
docker image inspect "${DOCKER_IMAGE}" &> /dev/null ||
docker pull "${DOCKER_IMAGE}" > /dev/null
docker_run \
--entrypoint java \
"${DOCKER_IMAGE}" \
-jar /opt/asciidoc-confluence-publisher-docker.jar \
"${@}"
}
function base64() {
local DOCKER_IMAGE="busybox:1.34.1"
docker image inspect "${DOCKER_IMAGE}" &> /dev/null ||
docker pull "${DOCKER_IMAGE}" > /dev/null
docker_run \
--entrypoint base64 \
"${DOCKER_IMAGE}" \
"${@}"
}
function jq() {
local DOCKER_IMAGE="imega/jq:1.6"
docker image inspect "${DOCKER_IMAGE}" &> /dev/null ||
docker pull "${DOCKER_IMAGE}" > /dev/null
docker_run \
--entrypoint jq \
"${DOCKER_IMAGE}" \
"${@}"
}
function yq() {
local DOCKER_IMAGE="mikefarah/yq:4"
docker image inspect "${DOCKER_IMAGE}" &> /dev/null ||
docker pull "${DOCKER_IMAGE}" > /dev/null
docker_run \
--entrypoint yq \
"${DOCKER_IMAGE}" \
"${@}"
}
function aws() {
local DOCKER_IMAGE="conmob/aws:2.2.42-kubectl-1.22.3-helm-3.7.2-terraform-1.1.2"
docker image inspect "${DOCKER_IMAGE}" &> /dev/null ||
docker pull "${DOCKER_IMAGE}" > /dev/null
docker_run \
--env AWS_DEFAULT_REGION \
--env AWS_DEFAULT_OUTPUT \
--env AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY \
--env AWS_SESSION_TOKEN \
--entrypoint aws \
"${DOCKER_IMAGE}" \
"${@}"
}
function kubectl() {
local DOCKER_IMAGE="conmob/aws:2.2.42-kubectl-1.22.3-helm-3.7.2-terraform-1.1.2"
docker image inspect "${DOCKER_IMAGE}" &> /dev/null ||
docker pull "${DOCKER_IMAGE}" > /dev/null
docker_run \
--env AWS_DEFAULT_REGION \
--env AWS_DEFAULT_OUTPUT \
--env AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY \
--env AWS_SESSION_TOKEN \
--entrypoint kubectl \
"${DOCKER_IMAGE}" \
"${@}"
}
function helm() {
local DOCKER_IMAGE="conmob/aws:2.2.42-kubectl-1.22.3-helm-3.7.2-terraform-1.1.2"
docker image inspect "${DOCKER_IMAGE}" &> /dev/null ||
docker pull "${DOCKER_IMAGE}" > /dev/null
docker_run \
--env HELM_EXPERIMENTAL_OCI \
--env AWS_DEFAULT_REGION \
--env AWS_DEFAULT_OUTPUT \
--env AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY \
--env AWS_SESSION_TOKEN \
--entrypoint helm \
"${DOCKER_IMAGE}" \
"${@}"
}