Compare commits
2 Commits
lesson3-ci
...
lesson7-ap
| Author | SHA1 | Date | |
|---|---|---|---|
| ebb85c44bc | |||
|
|
cfdd245655 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,5 +3,6 @@
|
|||||||
data/gitlab-test/gitlab
|
data/gitlab-test/gitlab
|
||||||
data/gitlab-test/postgresql
|
data/gitlab-test/postgresql
|
||||||
data/gitlab-test/redis
|
data/gitlab-test/redis
|
||||||
|
data/gitlab-test/gitlab-runner*
|
||||||
|
|
||||||
Addons/
|
Addons/gpg*
|
||||||
|
|||||||
2
Addons/api-cleaner/.env.example
Normal file
2
Addons/api-cleaner/.env.example
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
GITLAB_TOKEN=glpat-XXX
|
||||||
|
GITLAB_SERVER=https://git.realmanual.ru/api/v4
|
||||||
12
Addons/api-cleaner/gitlab_cleaner.sh
Executable file
12
Addons/api-cleaner/gitlab_cleaner.sh
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source .env
|
||||||
|
|
||||||
|
USERS_LIST=$(curl -s --header "Authorization: Bearer $GITLAB_TOKEN" "${GITLAB_SERVER}/users?per_page=100" | jq -r '.[] | select( .state == "deactivated" and .is_admin == false).id')
|
||||||
|
|
||||||
|
echo $USERS_LIST
|
||||||
|
|
||||||
|
for user in ${USERS_LIST[@]}; do
|
||||||
|
echo "delete user_id: $user"
|
||||||
|
curl -s --request DELETE --header "Authorization: Bearer $GITLAB_TOKEN" "${GITLAB_SERVER}/users/$user"
|
||||||
|
done
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
# полный реферерс тут
|
|
||||||
# https://docs.gitlab.com/ee/ci/yaml/index.html
|
|
||||||
# а тут доступные переменные
|
|
||||||
# https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
|
|
||||||
|
|
||||||
image: docker:20.10.16
|
|
||||||
|
|
||||||
variables:
|
|
||||||
REGISTRY: hub.bildme.ru
|
|
||||||
IMAGE_NAME: $REGISTRY/$CI_PROJECT_PATH:latest
|
|
||||||
VERSION: 0.0.1
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- build
|
|
||||||
- deploy
|
|
||||||
|
|
||||||
build_main:
|
|
||||||
stage: build
|
|
||||||
variables:
|
|
||||||
DOCKER_BASEIMAGE: golang:latest
|
|
||||||
before_script:
|
|
||||||
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $REGISTRY
|
|
||||||
script:
|
|
||||||
- docker build --pull --build-arg DOCKER_BASEIMAGE=${DOCKER_BASEIMAGE} -build-arg VERSION=${VERSION} -t $IMAGE_NAME .
|
|
||||||
- docker push $IMAGE_NAME
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
deploy_prod:
|
|
||||||
image: hub.realmanual.ru/pub/openssh-client:latest
|
|
||||||
stage: deploy
|
|
||||||
variables:
|
|
||||||
DOCKER_SERVER: 192.168.9.199
|
|
||||||
before_script:
|
|
||||||
- eval $(ssh-agent -s)
|
|
||||||
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
|
||||||
- mkdir -p ~/.ssh
|
|
||||||
- chmod 700 ~/.ssh
|
|
||||||
- ssh-keyscan ${DOCKER_SERVER} >> ~/.ssh/known_hosts
|
|
||||||
- chmod 644 ~/.ssh/known_hosts
|
|
||||||
script:
|
|
||||||
- ssh root@${DOCKER_SERVER} "docker rm -f main-go; docker pull hub.bildme.ru/firstgroup/go-site && docker run --rm --name main-go -p 3000:3000 hub.bildme.ru/firstgroup/go-site:latest"
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
ARG DOCKER_BASEIMAGE
|
|
||||||
FROM ${DOCKER_BASEIMAGE}
|
|
||||||
|
|
||||||
LABEL maintainer="${DOCKER_MAINTAINER:-vasyakrg@gmail.com}"
|
|
||||||
|
|
||||||
ADD ./app /app/
|
|
||||||
WORKDIR /app/
|
|
||||||
|
|
||||||
ARG VERSION=0.0.1
|
|
||||||
ENV VERSION=${VERSION}
|
|
||||||
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=auto go build -a -ldflags="-X 'main.Version=v${VERSION}'" -installsuffix cgo -o main .
|
|
||||||
|
|
||||||
|
|
||||||
FROM alpine
|
|
||||||
ENV LANGUAGE="ru"
|
|
||||||
COPY --from=0 /app/ /
|
|
||||||
RUN apk add --no-cache ca-certificates &&\
|
|
||||||
chmod +x main
|
|
||||||
|
|
||||||
CMD [ "./main" ]
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
func indexHandler(w http.ResponseWriter, r *http.Request) {
|
|
||||||
w.Write([]byte("<h1>Hello World!</h1>"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
port := os.Getenv("PORT")
|
|
||||||
if port == "" {
|
|
||||||
port = "3000"
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Print("\nim run in http://127.0.0.1:", port)
|
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
|
||||||
mux.HandleFunc("/", indexHandler)
|
|
||||||
http.ListenAndServe(":"+port, mux)
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
docker pull hub.bildme.ru/firstgroup/go-site:latest
|
|
||||||
docker run --rm --name main-go -p 3000:3000 hub.bildme.ru/firstgroup/go-site:latest
|
|
||||||
Reference in New Issue
Block a user