up
This commit is contained in:
@@ -10,18 +10,26 @@ variables:
|
||||
GITLAB: git.bildme.ru
|
||||
IMAGE_NAME: $REGISTRY/$CI_PROJECT_PATH:latest
|
||||
RELEASE_NAME: go-site
|
||||
VERSION: 0.0.3
|
||||
VERSION: 0.0.5
|
||||
PACKAGE_REGISTRY_URL: https://${GITLAB}/api/v4/projects/${CI_PROJECT_ID}/packages/generic/${RELEASE_NAME}/${VERSION}
|
||||
|
||||
stages:
|
||||
- build
|
||||
- push
|
||||
- artifacts
|
||||
- release
|
||||
- deploy
|
||||
|
||||
.rules: &rules
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
when: never
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
|
||||
build_main:
|
||||
stage: build
|
||||
image: golang:latest
|
||||
<<: *rules
|
||||
script:
|
||||
- cd app
|
||||
- CGO_ENABLED=0 GOOS=linux GO111MODULE=auto go build -a -ldflags="-X 'main.Version=v${VERSION}'" -installsuffix cgo -o go-site .
|
||||
@@ -33,6 +41,7 @@ build_main:
|
||||
|
||||
push_image:
|
||||
stage: push
|
||||
<<: *rules
|
||||
before_script:
|
||||
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $REGISTRY
|
||||
script:
|
||||
@@ -43,10 +52,7 @@ push_image:
|
||||
|
||||
package:
|
||||
stage: release
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
when: never
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
<<: *rules
|
||||
before_script:
|
||||
- apk add curl
|
||||
script:
|
||||
@@ -57,10 +63,7 @@ package:
|
||||
release:
|
||||
stage: release
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
when: never
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
<<: *rules
|
||||
script:
|
||||
- echo "Release ${RELEASE_NAME}"
|
||||
release:
|
||||
@@ -74,8 +77,9 @@ release:
|
||||
url: '${PACKAGE_REGISTRY_URL}/${RELEASE_NAME}'
|
||||
|
||||
deploy_prod:
|
||||
image: hub.realmanual.ru/pub/openssh-client:latest
|
||||
stage: deploy
|
||||
image: hub.realmanual.ru/pub/openssh-client:latest
|
||||
<<: *rules
|
||||
variables:
|
||||
DOCKER_SERVER: 192.168.9.199
|
||||
before_script:
|
||||
|
@@ -6,8 +6,10 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var Version = "0.0.1"
|
||||
|
||||
func indexHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("<h1>Hello World!</h1>"))
|
||||
w.Write([]byte("<h1>Hello World, im ver:"+Version+" !</h1>"))
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -16,7 +18,7 @@ func main() {
|
||||
port = "3000"
|
||||
}
|
||||
|
||||
fmt.Print("\nim run in http://127.0.0.1:", port)
|
||||
fmt.Print("\nVersion:", Version, ", Im run in http://127.0.0.1:", port)
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", indexHandler)
|
||||
|
Reference in New Issue
Block a user