Skip to content

Commit

Permalink
circleci updated to be able to build with private package repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Marinov committed May 8, 2020
1 parent 6a7e71d commit 05322d5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
17 changes: 16 additions & 1 deletion .circleci/config.yml
Expand Up @@ -16,6 +16,8 @@ jobs:
- run:
name: External dependencies
command: |
GOPRIVATE="github.com/Financial-Times"
git config --global url."https://$GITHUB_USERNAME:$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"
GO111MODULE=off go get -u github.com/mattn/goveralls
GO111MODULE=off go get -u github.com/jstemmer/go-junit-report
GO111MODULE=off go get -u github.com/myitcv/gobin
Expand All @@ -31,6 +33,8 @@ jobs:
- run:
name: Go build
command: |
GOPRIVATE="github.com/Financial-Times"
git config --global url."https://$GITHUB_USERNAME:$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"
go generate ./cmd/content-rw-elasticsearch
go build -mod=readonly -v ./cmd/content-rw-elasticsearch
- run:
Expand All @@ -53,20 +57,24 @@ jobs:
- setup_remote_docker
- run:
name: Build Dockerfile
command: docker build .
command: docker build --build-arg GITHUB_USERNAME="$GITHUB_USERNAME" --build-arg GITHUB_TOKEN="$GITHUB_TOKEN" .
dredd:
working_directory: /go/src/github.com/Financial-Times/content-rw-elasticsearch
docker:
- image: golang:1
environment:
GOPATH: /go
ELASTICSEARCH_SAPI_ENDPOINT: http://localhost:9000
GITHUB_USERNAME: ${GITHUB_USERNAME}
GITHUB_TOKEN: ${GITHUB_TOKEN}
- image: peteclarkft/ersatz:stable
steps:
- checkout
- run:
name: Download dredd
command: |
GOPRIVATE="github.com/Financial-Times"
git config --global url."https://$GITHUB_USERNAME:$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"
curl -sL https://deb.nodesource.com/setup_11.x | bash -
DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs=11.\*
npm install -g --unsafe-perm --loglevel warn --user 0 --no-progress dredd@11.2.19
Expand All @@ -80,6 +88,8 @@ jobs:
- run:
name: Go Build
command: |
GOPRIVATE="github.com/Financial-Times"
git config --global url."https://$GITHUB_USERNAME:$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"
go generate ./cmd/content-rw-elasticsearch
go build -mod=readonly -v ./cmd/content-rw-elasticsearch
- run:
Expand All @@ -91,6 +101,11 @@ jobs:
- image: circleci/golang:1
steps:
- checkout
- run:
name: Github private config
command: |
GOPRIVATE="github.com/Financial-Times"
git config --global url."https://$GITHUB_USERNAME:$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"
- snyk/scan:
monitor-on-build: false
severity-threshold: medium
Expand Down
7 changes: 6 additions & 1 deletion Dockerfile
Expand Up @@ -6,11 +6,16 @@ ENV ORG_PATH="github.com/Financial-Times"
ENV SRC_FOLDER="${GOPATH}/src/${ORG_PATH}/${PROJECT}"
ENV BUILDINFO_PACKAGE="${ORG_PATH}/service-status-go/buildinfo."

ARG GITHUB_USERNAME
ARG GITHUB_TOKEN

COPY . ${SRC_FOLDER}
WORKDIR ${SRC_FOLDER}

# Install statik cli tool in GOPATH in order to successfully execute the go generate command
RUN GO111MODULE=off go get -u github.com/myitcv/gobin \
RUN echo "machine github.com login $GITHUB_USERNAME password $GITHUB_TOKEN" > ~/.netrc \
&& GOPRIVATE="github.com/Financial-Times" \
&& GO111MODULE=off go get -u github.com/myitcv/gobin \
# Get statik version from go.mod of the project
&& STATIK_VERSION="$(go list -mod=readonly -m all | grep statik | cut -d ' ' -f2)" \
&& gobin github.com/rakyll/statik@${STATIK_VERSION} \
Expand Down
5 changes: 2 additions & 3 deletions cmd/content-rw-elasticsearch/main.go
Expand Up @@ -7,7 +7,7 @@ import (
"os"
"time"

"github.com/jawher/mow.cli"
cli "github.com/jawher/mow.cli"

"github.com/Financial-Times/go-logger/v2"
"github.com/Financial-Times/message-queue-gonsumer/consumer"
Expand Down Expand Up @@ -115,10 +115,9 @@ func main() {
EnvVar: "BASE_API_URL",
})

// todo config add to helm
internalContentAPIURL := app.String(cli.StringOpt{
Name: "internal-content-api-url",
Value: "",
Value: "http://internal-content-api-url:8080",
Desc: "URL of the API uses to retrieve lists data from",
EnvVar: "INTERNAL_CONTENT_API_URL",
})
Expand Down
2 changes: 2 additions & 0 deletions helm/content-rw-elasticsearch/templates/deployment.yaml
Expand Up @@ -61,6 +61,8 @@ spec:
key: aws.secret_access_key
- name: PUBLIC_CONCORDANCES_ENDPOINT
value: "{{ .Values.env.PUBLIC_CONCORDANCES_ENDPOINT }}"
- name: INTERNAL_CONTENT_API_URL
value: "{{ .Values.env.INTERNAL_CONTENT_API_URL }}"
- name: "BASE_API_URL"
valueFrom:
configMapKeyRef:
Expand Down
1 change: 1 addition & 0 deletions helm/content-rw-elasticsearch/values.yaml
Expand Up @@ -18,3 +18,4 @@ env:
KAFKA_TOPIC: ""
KAFKA_CONCURRENT_PROCESSING: ""
PUBLIC_CONCORDANCES_ENDPOINT: ""
INTERNAL_CONTENT_API_URL: ""

0 comments on commit 05322d5

Please sign in to comment.