Skip to content

Commit

Permalink
Merge pull request #4 from IgorPolyakov/main
Browse files Browse the repository at this point in the history
CI\CD, migrate to pSQL, user & game work now
  • Loading branch information
sea-kg authored Apr 19, 2024
2 parents 05d80e0 + 1378419 commit 1cb4ef2
Show file tree
Hide file tree
Showing 29 changed files with 757 additions and 598 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dckr_mysql
sql
Dockerfile
docker-compose.yml
docker-compose.yml
pg-data
58 changes: 58 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI/CD

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
# раскоментить когда будет доступ до DockerHub
# build:
# name: Build and Push
# runs-on: ubuntu-latest

# steps:
# - name: Check out code
# uses: actions/checkout@v2

# - name: Set up Go
# uses: actions/setup-go@v2
# with:
# go-version: '1.22'

# - name: Build Docker Image
# run: docker build . -t sea-kg/ctf01d:latest

# - name: Log in to DockerHub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

# - name: Push Docker Image
# run: docker push sea-kg/ctf01d:latest
check-dependencies:
name: Check dependencies with nancy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- name: WriteGoList
run: cd src && go list -json -m all > ../go.list
- name: Nancy
uses: sonatype-nexus-community/nancy-github-action@main
continue-on-error: true
lint-code:
name: Lint with golangci-lint
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
go_version: 1.22
workdir: ./src
21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
# ctf01d-training-platform

Service used go && mysql
Service used go && psql

[http://localhost:4102/](http://localhost:4102/)

## Install requriments

```shell
$ sudo apt install golang
$ go get github.com/go-sql-driver/mysql
$ go get github.com/jmoiron/sqlx
$ go get github.com/gorilla/mux
$ go mod download
```

## Build server

```shell
$ cd src
$ go build server.go
$ go build main.go
```

## Run local dev server

```shell
$ cd src
$ SERVICE2_GO_MYSQL_HOST=service2_go_db SERVICE2_GO_MYSQL_DBNAME=service2_go SERVICE2_GO_MYSQL_USER=service2_go SERVICE2_GO_MYSQL_PASSWORD=service2_go go run server.go
$ go run main.go
```

## Run DB for local devlopment
Expand All @@ -50,14 +48,5 @@ $ docker run -d --name ctf01d-postgres -e POSTGRES_DB=ctf01d -e POSTGRES_USER=po
attach to container

```shell
# TODO
```

### mysql -- deprecated

run local container


```shell
$ docker run --name service2_go_db -e MYSQL_ROOT_PASSWORD=service2_go -e MYSQL_DATABASE=service2_go -e MYSQL_USER=service2_go -e MYSQL_PASSWORD=service2_go -p 3306:3306 -d mysql:latest
$ docker exec -it ctf01d-postgres psql -U postgres
```
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- [ ] Авторизация (пока простая)
- [ ] Регистрацию думаю пока не надо - пусть через админку будет добавление новых
- [x] База данных (postgre) - версионирование чтобы проще было обновлять сервер.

- [ ] CI/CD - линтеры, securego/gosec, сборка контейнера и отправка в regestry

## Админ

Expand Down
Loading

0 comments on commit 1cb4ef2

Please sign in to comment.