-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into 'master'
Develop See merge request golang-general/echo-demo-app!26
- Loading branch information
Showing
40 changed files
with
537 additions
and
432 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
HOST= | ||
PORT= | ||
DB_USER= | ||
DB_PASSWORD= | ||
DB_DRIVER= | ||
DB_NAME= | ||
DB_HOST= | ||
DB_PORT= | ||
#The application host name | ||
HOST=localhost | ||
#The application port to get access from the docker container | ||
PORT=7788 | ||
|
||
#Parameters for getting the access to the database | ||
DB_USER=local_user | ||
DB_PASSWORD=password | ||
DB_DRIVER=mysql | ||
DB_NAME=echo_example_docker | ||
DB_HOST=echo_mysql | ||
DB_PORT=33060 | ||
|
||
#IDs of user group and user which will be used inside docker container by the linter to make changes to files | ||
COMPOSE_USER_ID=999 | ||
COMPOSE_GROUP_ID=999 | ||
|
||
#The application and the database will be accessible from the host machine on these ports | ||
EXPOSE_PORT=7788 | ||
EXPOSE_DB_PORT=3306 | ||
|
||
#Secret keys for the access token and refresh token signing | ||
ACCESS_SECRET=access_secret | ||
REFRESH_SECRET=refresh_secret |
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 |
---|---|---|
|
@@ -17,17 +17,18 @@ stages: | |
- deploy | ||
|
||
lint: | ||
image: golangci/golangci-lint:v1.36.0 | ||
image: golangci/golangci-lint:v1.51.0 | ||
stage: test | ||
before_script: | ||
- go get -v github.com/swaggo/swag/cmd/swag | ||
- $GOPATH/bin/swag init -g cmd/main.go | ||
- cp .env.testing.gitlab-ci .env.testing | ||
- go install -v github.com/swaggo/swag/cmd/[email protected] | ||
- swag init -g cmd/main.go | ||
script: | ||
- golangci-lint run -v | ||
- golangci-lint run | ||
allow_failure: true | ||
|
||
migrations: | ||
image: golang:1.13.3-alpine3.10 | ||
image: golang:1.21.4-alpine3.18 | ||
services: | ||
- mysql:5.7 | ||
tags: | ||
|
@@ -37,15 +38,15 @@ migrations: | |
before_script: | ||
- apk add --no-cache --update git build-base openssh-client | ||
- cp .env.testing.gitlab-ci .env | ||
- go get -v github.com/swaggo/swag/cmd/swag | ||
- go install -v github.com/swaggo/swag/cmd/swag@v1.8.10 | ||
- $GOPATH/bin/swag init -g cmd/main.go | ||
script: | ||
- go get -v ./... | ||
- go run migrations/entry.go --env-path=./ --verbose | ||
- go run migrations/entry.go --rollback --env-path=./ --verbose | ||
|
||
test: | ||
image: golang:1.13.3-alpine3.10 | ||
image: golang:1.20.1-alpine3.17 | ||
services: | ||
- mysql:5.7 | ||
tags: | ||
|
@@ -55,8 +56,8 @@ test: | |
before_script: | ||
- apk add --no-cache --update git build-base openssh-client | ||
- cp .env.testing.gitlab-ci .env.testing | ||
- go get -v github.com/swaggo/swag/cmd/swag | ||
- $GOPATH/bin/swag init -g cmd/main.go | ||
- go install -v github.com/swaggo/swag/cmd/swag@v1.8.10 | ||
- swag init -g cmd/main.go | ||
script: | ||
- go get -v ./... | ||
- go test -v ./... | ||
|
@@ -77,13 +78,10 @@ build: | |
- docker push $CI_REGISTRY_IMAGE:staging | ||
|
||
deploy staging: | ||
image: golang:1.13.3-alpine3.10 | ||
image: golang:1.20.1-alpine3.17 | ||
environment: | ||
name: staging | ||
when: manual | ||
only: | ||
refs: | ||
- develop | ||
tags: | ||
- dind | ||
- docker | ||
|
@@ -95,15 +93,11 @@ deploy staging: | |
- chmod 600 ~/.ssh/id_rsa | ||
- eval "$(ssh-agent -s)" | ||
- ssh-add ~/.ssh/id_rsa | ||
- ssh-keyscan -H $STAGING_IP >> ~/.ssh/known_hosts | ||
- GOOS=linux GOARCH=386 go build -o entry migrations/entry.go | ||
- ssh-keyscan -p 221 -H $STAGING_IP >> ~/.ssh/known_hosts | ||
script: | ||
- ssh dev@${STAGING_IP} "mkdir -p ${PROJECT_PATH}" | ||
- scp -r ${STAGING_ENV} dev@${STAGING_IP}:${PROJECT_PATH}/.env | ||
- scp -r ${MIGRATION_ENV} dev@${STAGING_IP}:${PROJECT_PATH}/.env.migration | ||
- scp -r ./deploy/docker-compose.yml dev@${STAGING_IP}:${PROJECT_PATH}/docker-compose.yml | ||
- ssh dev@$STAGING_IP "docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}; | ||
- ssh dev@${STAGING_IP} -p 221 "mkdir -p ${PROJECT_PATH}" | ||
- scp -P 221 -r ${STAGING_ENV} dev@${STAGING_IP}:${PROJECT_PATH}/.env | ||
- scp -P 221 -r ./deploy/compose.yml dev@${STAGING_IP}:${PROJECT_PATH}/compose.yml | ||
- ssh dev@$STAGING_IP -p 221 "docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}; | ||
docker pull ${CI_REGISTRY}/${CI_PROJECT_PATH}:staging; | ||
docker-compose -f ${PROJECT_PATH}/docker-compose.yml up -d" | ||
- scp -r ./entry dev@${STAGING_IP}:${PROJECT_PATH}/entry | ||
- ssh dev@${STAGING_IP} "${PROJECT_PATH}/entry --env-path=${PROJECT_PATH} --env-file=.env.migration --verbose" | ||
docker compose -f ${PROJECT_PATH}/compose.yml up -d" |
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 |
---|---|---|
|
@@ -7,23 +7,23 @@ import ( | |
"fmt" | ||
) | ||
|
||
// @title Echo Demo App | ||
// @version 1.0 | ||
// @description This is a demo version of Echo app. | ||
// @title Echo Demo App | ||
// @version 1.0 | ||
// @description This is a demo version of Echo app. | ||
|
||
// @contact.name NIX Solutions | ||
// @contact.url https://www.nixsolutions.com/ | ||
// @contact.email [email protected] | ||
// @contact.name NIX Solutions | ||
// @contact.url https://www.nixsolutions.com/ | ||
// @contact.email [email protected] | ||
|
||
// @securityDefinitions.apikey ApiKeyAuth | ||
// @in header | ||
// @name Authorization | ||
// @securityDefinitions.apikey ApiKeyAuth | ||
// @in header | ||
// @name Authorization | ||
|
||
// @BasePath / | ||
// @BasePath / | ||
func main() { | ||
cfg := config.NewConfig() | ||
|
||
docs.SwaggerInfo.Host = fmt.Sprintf("%s:%s", cfg.HTTP.Host, cfg.HTTP.ExposePort) | ||
docs.SwaggerInfo.Host = fmt.Sprintf("%s:%s", cfg.HTTP.Host, cfg.HTTP.Port) | ||
|
||
application.Start(cfg) | ||
} |
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
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,4 +1,3 @@ | ||
version: '3.7' | ||
services: | ||
echo-golinter: | ||
build: | ||
|
Oops, something went wrong.