-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added GOPRIVATE settings in agent artifact workflows
- Loading branch information
1 parent
a2a7a30
commit 6036e94
Showing
11 changed files
with
170 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,15 @@ jobs: | |
token: ${{ secrets.GHCR_TOKEN }} | ||
ssh-key: ${{ secrets.CHECK_AGENT_ACCESS }} | ||
submodules: 'recursive' | ||
|
||
- name: Set up Git credentials for Go | ||
run: | | ||
git config --global url."https://${{ secrets.GHCR_TOKEN }}:@github.com/".insteadOf "https://github.com/" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GHCR_TOKEN }} | ||
|
||
- name: Set up GOPRIVATE | ||
run: echo "GOPRIVATE=your.private.repo" >> $GITHUB_ENV | ||
|
||
- name: Caching Go Modules and Build Cache | ||
uses: actions/cache@v3 | ||
|
@@ -49,7 +58,12 @@ jobs: | |
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/middleware-labs/mw-host-agent | ||
images: ghcr.io/middleware-labs/mw-host-agent | ||
|
||
# - name: Add SSH key | ||
# uses: webfactory/[email protected] | ||
# with: | ||
# ssh-private-key: ${{ secrets.INNODB_SSH_PRIVATE_KEY_BASE64 }} | ||
|
||
- name: Build and Push | ||
uses: docker/build-push-action@v3 | ||
|
@@ -58,6 +72,10 @@ jobs: | |
file: Dockerfiles/DockerfileLinux | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
build-args: AGENT_VERSION=${{ github.event.inputs.tag || steps.meta.outputs.tags }} | ||
build-args: | | ||
AGENT_VERSION=${{ github.event.inputs.tag || steps.meta.outputs.tags }} | ||
INNODB_SSH_PRIVATE_KEY_BASE64=${{ secrets.INNODB_SSH_PRIVATE_KEY_BASE64 }} | ||
secrets: | | ||
tags: | | ||
ghcr.io/middleware-labs/mw-host-agent:${{ github.event.inputs.tag || steps.meta.outputs.tags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,40 @@ | ||
FROM golang:1.22.1 as build | ||
RUN apt-get update && apt-get install -y ca-certificates openssl | ||
FROM golang:1.22.2 AS build | ||
RUN apt-get update && apt-get install -y ca-certificates openssl git openssh-client | ||
|
||
RUN update-ca-certificates | ||
COPY . . | ||
ARG AGENT_VERSION | ||
ENV AGENT_VERSION=$AGENT_VERSION | ||
# Optionally, copy your private SSH key to the container (for private repository access) | ||
# COPY innoparser_rsa /root/.ssh/innoparser_rsa | ||
RUN mkdir -p /root/.ssh && chmod 700 /root/.ssh | ||
ARG INNODB_SSH_PRIVATE_KEY | ||
# RUN cp innoparser_rsa /root/.ssh/innoparser_rsa && \ | ||
RUN echo "$INNODB_SSH_PRIVATE_KEY_BASE64" | base64 -d > /root/.ssh/innoparser_rsa && \ | ||
chmod 600 /root/.ssh/innoparser_rsa | ||
RUN ssh-keygen -y -f /root/.ssh/innoparser_rsa | ||
ENV GOPATH=/ | ||
RUN go mod tidy | ||
ENV GOPRIVATE=github.com/middleware-labs | ||
|
||
|
||
|
||
# Add GitHub SSH host key to known hosts | ||
RUN ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts | ||
|
||
# Set up SSH agent and add your private key (if needed) | ||
RUN eval $(ssh-agent -s) && \ | ||
ssh-add /root/.ssh/innoparser_rsa && \ | ||
ssh-keygen -y -f /root/.ssh/innoparser_rsa | ||
|
||
# Configure Git to use SSH (if needed) | ||
RUN git config --global url."ssh://[email protected]/".insteadOf "https://github.com/" | ||
|
||
RUN eval $(ssh-agent -s) && \ | ||
ssh-add /root/.ssh/innoparser_rsa && \ | ||
GOPRIVATE=github.com/middleware-labs go mod tidy | ||
RUN CGO_ENABLED=0 go build -ldflags "-s -w -X main.agentVersion=${AGENT_VERSION}" -o /tmp/mw-agent cmd/host-agent/main.go | ||
|
||
FROM busybox:glibc as prod | ||
FROM busybox:glibc AS prod | ||
RUN mkdir -p /var/log | ||
RUN mkdir -p /opt/mw-agent/bin | ||
WORKDIR /opt/mw-agent | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM golang:1.22.2 AS build | ||
RUN apt-get update && apt-get install -y ca-certificates openssl git openssh-client | ||
RUN update-ca-certificates | ||
COPY . . | ||
ENV GOPATH=/ | ||
ARG AGENT_VERSION | ||
ENV AGENT_VERSION=$AGENT_VERSION | ||
ENV GOPRIVATE=github.com/middleware-labs | ||
|
||
RUN mkdir -p /root/.ssh | ||
RUN cp innoparser_rsa /root/.ssh/innoparser_rsa | ||
RUN chmod 600 /root/.ssh/innoparser_rsa | ||
RUN ssh-keygen -y -f /root/.ssh/innoparser_rsa | ||
RUN eval $(ssh-agent -s) && ssh-add /root/.ssh/innoparser_rsa | ||
|
||
RUN mkdir -p -m 0600 /root/.ssh && touch /root/.ssh/known_hosts | ||
RUN ssh-keyscan github.com > /root/.ssh/known_hosts | ||
RUN git config --global url."ssh://[email protected]/".insteadOf "https://github.com/" | ||
|
||
RUN go mod tidy | ||
RUN CGO_ENABLED=0 go build -ldflags "-s -w -X main.agentVersion=${AGENT_VERSION}" -o /tmp/mw-agent cmd/host-agent/main.go | ||
|
||
FROM busybox:glibc AS prod | ||
RUN mkdir -p /var/log | ||
RUN mkdir -p /opt/mw-agent/bin | ||
WORKDIR /opt/mw-agent | ||
COPY --from=build /etc/ssl/certs /etc/ssl/certs | ||
COPY --from=build /tmp/mw-agent /opt/mw-agent/bin/mw-agent | ||
COPY package-tooling/otel-config.yaml.sample /etc/mw-agent/otel-config.yaml | ||
CMD ["/opt/mw-agent/bin/mw-agent", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.