Skip to content

Commit

Permalink
Merge pull request #20 from zhangzerui20/main
Browse files Browse the repository at this point in the history
update workflows
  • Loading branch information
zhangzerui20 authored Jan 24, 2022
2 parents 83b8ecf + ca5f556 commit cc31414
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 5 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: DockerImage

on:
workflow_dispatch:
inputs:
polaris_controller_tag:
description: 'tag for polaris-controller'
required: true
docker_username:
description: 'docker username for login'
required: true
docker_password:
description: 'docker password for login'
required: true

jobs:
release:
name: Release Polaris Docker Image
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux]
goarch: [amd64]
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.polaris_tag }}

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.5

- name: Build
id: build
env:
DOCKER_TAG: ${{ github.event.inputs.polaris_controller_tag }}
DOCKER_USER: ${{ github.event.inputs.docker_username }}
DOCKER_PASS: ${{ github.event.inputs.docker_password }}
run: |
make push-image REPO=polarismesh/polaris-controller IMAGE_TAG=${DOCKER_TAG} DOCKER_USER=${DOCKER_USER} DOCKER_PASS=${DOCKER_PASS}
5 changes: 4 additions & 1 deletion .github/workflows/go.yml → .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Go
name: Testing

on:
push:
Expand All @@ -21,5 +21,8 @@ jobs:
- name: vert check
run: bash vert.sh -install && bash vert.sh

- name: Build polairs-controller
run: make build

- name: Test
run: go test -v ./...
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
.PHONY: build

REGISTRY = docker.io
REPO = polaris_mesh_test/polaris-controller
IMAGE_TAG = v1.0.0

build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o ./bin/polaris-controller ./cmd/polaris-controller/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o ./bin/polaris-controller ./cmd/polaris-controller/main.go

build-image:
docker build . -f ./docker/Dockerfile -t $(REGISTRY)/$(REPO):$(IMAGE_TAG)

push-image: build build-image login
docker push $(REGISTRY)/$(REPO):$(IMAGE_TAG)

login:
@docker login --username=$(DOCKER_USER) --password=$(DOCKER_PASS)
8 changes: 5 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
FROM alpine:latest
RUN apk update \
&& apk add tzdata \
&& apk add --no-cache bash \
&& apk add curl \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone

RUN mkdir -p /polaris-controller/log && \
chmod -R 755 /polaris-controller

WORKDIR /polaris-controller
COPY ../bin/polaris-controller /polaris-controller/polaris-controller

ENTRYPOINT ["/polaris-controller/polaris-controller"]
COPY ./bin/polaris-controller /polaris-controller/polaris-controller
COPY ./docker/polaris.yaml /polaris-controller/polaris.yaml
4 changes: 4 additions & 0 deletions docker/polaris.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
global:
serverConnector:
addresses:
- 127.0.0.2:8091

0 comments on commit cc31414

Please sign in to comment.