-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move backend into main repo
- Loading branch information
Showing
75 changed files
with
12,846 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Backend Build&Push to Prod ECR | ||
on: | ||
push: | ||
branches: [ 'develop' ] | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
name: Build Image | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.PROD_AWS_ROLE }} | ||
aws-region: eu-west-2 | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: cloud-web | ||
IMAGE_TAG: latest | ||
run: | | ||
export COMMIT_SHA=$(git rev-parse --short HEAD) | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --build-arg COMMIT_SHA=${COMMIT_SHA} -f backend/Dockerfile . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
working-directory: backend | ||
|
||
restart: | ||
needs: build | ||
name: Restart ECS service | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.PROD_AWS_ROLE}} | ||
aws-region: eu-west-2 | ||
|
||
- name: Restart ECS | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
AWS_REGION: eu-west-2 | ||
run: | | ||
aws ecs update-service --cluster ${{ vars.ECS_CLUSTER_NAME }} --service ${{ vars.ECS_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION |
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Backend Build&Push to Test ECR | ||
on: | ||
push: | ||
branches: [ 'develop', 'feat/*' ] | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
name: Build Image | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.TEST_AWS_ROLE }} | ||
aws-region: eu-west-2 | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: cloud-web | ||
IMAGE_TAG: latest | ||
run: | | ||
export COMMIT_SHA=$(git rev-parse --short HEAD) | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --build-arg COMMIT_SHA=${COMMIT_SHA} . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
working-directory: backend | ||
|
||
restart: | ||
needs: build | ||
name: Restart ECS service | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.TEST_AWS_ROLE}} | ||
aws-region: us-east-1 | ||
|
||
- name: Restart ECS | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
AWS_REGION: eu-west-2 | ||
run: | | ||
aws ecs update-service --cluster ${{ vars.ECS_CLUSTER_NAME }} --service ${{ vars.ECS_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Backend release | ||
on: | ||
release: | ||
types: [released] | ||
jobs: | ||
binary: | ||
strategy: | ||
matrix: | ||
arch: [arm, arm64, amd64, 386] | ||
os: [linux, darwin, freebsd, windows] | ||
exclude: | ||
- os: darwin | ||
arch: arm | ||
- os: darwin | ||
arch: 386 | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.21.1 | ||
id: go | ||
|
||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
- name: Build | ||
run: | | ||
echo "Tag that is going to be used as digger version: ${{ github.event.release.tag_name }}" | ||
env GOOS=${{matrix.os}} GOARCH=${{matrix.arch}} CGO_ENABLED=0 go build -ldflags="-X digger/pkg/utils.version=${{ github.event.release.tag_name }}" -o digger-api ./ | ||
- name: Publish linux-x64 exec to github | ||
id: upload-release-asset-linux-x64 | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: 'digger-api' | ||
asset_name: digger-api-${{matrix.os}}-${{matrix.arch}} | ||
asset_content_type: application/octet-stream | ||
|
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Backend Go Tests | ||
on: | ||
push: | ||
branches: [ develop ] | ||
pull_request: | ||
|
||
jobs: | ||
|
||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Download Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.21.1 | ||
id: go | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v4 | ||
|
||
- name: Deps | ||
run: go get -v ./... | ||
working-directory: backend | ||
|
||
- name: Build | ||
run: go build | ||
working-directory: backend | ||
|
||
- name: Test | ||
run: go test -v ./... | ||
env: | ||
GITHUB_PAT_TOKEN: ${{ secrets.TOKEN_GITHUB }} | ||
working-directory: backend |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Dockerfile | ||
cloud |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
backend | ||
.idea/ | ||
.DS_Store | ||
venv/ | ||
**/__pycache__/ | ||
__azurite* | ||
./digger | ||
cloud | ||
*.env | ||
*.env.* | ||
.docker-compose-env | ||
controllers/database_test.db |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
FROM golang:1.21 as builder | ||
ARG COMMIT_SHA | ||
RUN echo "commit sha: ${COMMIT_SHA}" | ||
|
||
# Set the working directory | ||
WORKDIR $GOPATH/src/github.com/diggerhq/digger/backend | ||
|
||
# Copy all required source, blacklist files that are not required through `.dockerignore` | ||
COPY . . | ||
|
||
# Get the vendor library | ||
RUN go version | ||
|
||
# RUN vgo install | ||
|
||
# https://github.com/ethereum/go-ethereum/issues/2738 | ||
# Build static binary "-getmode=vendor" does not work with go-ethereum | ||
RUN go build -ldflags="-X 'main.Version=${COMMIT_SHA}'" -o backend | ||
|
||
# Multi-stage build will just copy the binary to an alpine image. | ||
FROM ubuntu:22.04 as runner | ||
ARG COMMIT_SHA | ||
WORKDIR /app | ||
|
||
RUN apt-get update && apt-get install -y ca-certificates && apt-get install -y git && apt-get clean all | ||
RUN update-ca-certificates | ||
|
||
RUN echo "commit sha: ${COMMIT_SHA}" | ||
|
||
# Set gin to production | ||
#ENV GIN_MODE=release | ||
|
||
# Expose the running port | ||
EXPOSE 3000 | ||
|
||
# Copy the binary to the corresponding folder | ||
COPY --from=builder /go/src/github.com/diggerhq/digger/backend/backend . | ||
ADD templates ./templates | ||
|
||
# Run the binary | ||
CMD ["/app/backend"] |
Oops, something went wrong.