Skip to content

Commit 9b48089

Browse files
committed
minor Dockerfile improvement, use minimal docker image to determine version
1 parent 03cd504 commit 9b48089

File tree

6 files changed

+27
-19
lines changed

6 files changed

+27
-19
lines changed

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM continuumio/miniconda3
2-
RUN conda update -n base -c defaults conda
3-
RUN apt-get update && apt-get install -y gnupg bash-completion build-essential
4-
RUN echo "deb http://packages.cloud.google.com/apt cloud-sdk-stretch main" >> /etc/apt/sources.list.d/google-cloud-sdk.list && \
2+
RUN conda update -n base -c defaults conda &&\
3+
apt-get update && apt-get install -y gnupg bash-completion build-essential &&\
4+
echo "deb http://packages.cloud.google.com/apt cloud-sdk-stretch main" >> /etc/apt/sources.list.d/google-cloud-sdk.list && \
55
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
66
apt-get update -y && apt-get install -y google-cloud-sdk kubectl postgresql nano dnsutils
77
COPY environment.yaml /environment.yaml
@@ -18,6 +18,7 @@ COPY *.sh *.py /usr/src/ckan-cloud-operator/
1818
RUN . /opt/conda/etc/profile.d/conda.sh && conda activate ckan-cloud-operator &&\
1919
cd /usr/src/ckan-cloud-operator && python3 -m pip install -e . &&\
2020
chmod +x /usr/src/ckan-cloud-operator/*.sh
21+
RUN apt-get install -y jq
2122
ENV EDITOR nano
2223
ENTRYPOINT ["/usr/src/ckan-cloud-operator/entrypoint.sh"]
2324

Dockerfile.jenkins-jnlp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM jenkins/jnlp-slave
22

33
USER root
4-
RUN apt-get update && apt-get install -y gnupg bash-completion build-essential &&\
4+
RUN apt-get update && apt-get install -y gnupg bash-completion build-essential jq &&\
55
echo "deb http://packages.cloud.google.com/apt cloud-sdk-stretch main" >> /etc/apt/sources.list.d/google-cloud-sdk.list && \
66
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
77
apt-get update -y && apt-get install -y google-cloud-sdk kubectl postgresql nano dnsutils &&\

Dockerfile.minimal

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:3.7-alpine
2+
RUN wget -qO /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/$(wget -qO - https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl &&\
3+
chmod +x /usr/local/bin/kubectl
4+
RUN apk --update add bash jq &&\
5+
apk add --virtual build-deps gcc python-dev musl-dev &&\
6+
apk add postgresql-dev
7+
COPY ckan_cloud_operator /usr/src/ckan-cloud-operator/ckan_cloud_operator
8+
COPY *.sh *.py /usr/src/ckan-cloud-operator/
9+
RUN python3 -m pip install psycopg2 pyyaml kubernetes click toml requests
10+
RUN python3 -m pip install -e /usr/src/ckan-cloud-operator
11+
ENTRYPOINT ["ckan-cloud-operator"]

README.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,13 @@ Add an environment (sudo is required to install the executable)
2727
sudo ckan-cloud-operator-env add <ENVIRONMENT_NAME> <PATH_TO_KUBECONFIG_FILE>
2828
```
2929

30-
**Important** re-run the following command before starting work on the operator to ensure correct version is installed.
31-
Once operator is installed you can verify correct version by running `ckan-cloud-operator cluster info`
32-
33-
Switch to the compatible operator version (may take a while on first run)
34-
35-
```
36-
sudo ckan-cloud-operator-env add <ENVIRONMENT_NAME> <PATH_TO_KUBECONFIG_FILE> "$(ckan-cloud-operator config get --key ckan-cloud-operator-image --raw)"
37-
```
38-
3930
Verify conection to the cluster and installed operator version (may take a while on first run or after upgrade of operator version)
4031

4132
```
4233
ckan-cloud-operator cluster info
4334
```
4435

36+
**Important** Re-run the add command and cluster info to verify compatible version is installed.
4537

4638
## Usage
4739

ckan-cloud-operator-env.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
help() {
3+
usage() {
44
echo Manage CKAN Cloud operator environments
55
echo
66
echo Usage: ./ckan-cloud-operator-env.sh "<COMMAND> [ARGS..]"
@@ -25,7 +25,7 @@ help() {
2525
echo " Installs a ckan-cloud-operator executable at /usr/local/bin/ckan-cloud-operator configured for the ENVIRONMENT_NAME"
2626
}
2727

28-
( [ "${1}" == "" ] || [ "${1}" == "-h" ] || [ "${1}" == "--help" ] ) && help && exit 1
28+
( [ "${1}" == "" ] || [ "${1}" == "-h" ] || [ "${1}" == "--help" ] ) && usage && exit 1
2929

3030
if [ "${1}" == "pull" ]; then
3131
if [ "${2}" == "latest" ]; then
@@ -60,10 +60,10 @@ elif [ "${1}" == "add" ]; then
6060
IMAGE="ckan-cloud-operator"
6161
else
6262
CMD=""
63-
if [ "${BUILD}" != "" ]; then
64-
IMAGE="${BUILD}"
63+
if [ "${BUILD}" == "" ]; then
64+
IMAGE=$(docker run --entrypoint bash -v ${KUBECONFIG_FILE}:/.kube-config -e KUBECONFIG=/.kube-config viderum/ckan-cloud-operator:minimal-20190416 -c "kubectl -n ckan-cloud get configmap/operator-conf -ojsonpath={.data.ckan-cloud-operator-image}")
6565
else
66-
IMAGE="viderum/ckan-cloud-operator:latest"
66+
IMAGE="${BUILD}"
6767
fi
6868
fi
6969
if [ "${KUBECONFIG_FILE}" == "minikube" ]; then

entrypoint.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/usr/bin/env bash
22

33
if [ "${1}" == "bash" ]; then
4-
exec bash --init-file <(echo 'source ~/.bashrc; eval "$(_CKAN_CLOUD_OPERATOR_COMPLETE=source ckan-cloud-operator)"')
4+
if [ "${2}" == "" ]; then
5+
exec bash --init-file <(echo 'source ~/.bashrc; eval "$(_CKAN_CLOUD_OPERATOR_COMPLETE=source ckan-cloud-operator)"')
6+
else
7+
exec "$@"
8+
fi
59
else
610
source ~/.bashrc
711
ckan-cloud-operator "$@"

0 commit comments

Comments
 (0)