Skip to content
Snippets Groups Projects
Commit c8fedf97 authored by Fajar Herawan's avatar Fajar Herawan
Browse files

Merge branch 'staging' into 'production'

Staging

See merge request !3
parents 6cf90ca3 3ba8f79c
Branches production
1 merge request!3Staging
POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_DB=
POSTGRES_HOST=
POSTGRES_PORT=
JWT_SECRET =
BASIC_AUTH_USERNAME =
BASIC_AUTH_PASSWORD =
\ No newline at end of file
.env
/tmp
/db-data
\ No newline at end of file
/db-data
/.vscode
\ No newline at end of file
stages: # List of stages for jobs, and their order of execution
- test
- build
- deploy
test-job:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'staging' || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'production')
script:
- echo 'Testing'
build-job: # This job runs in the build stage, which runs first.
stage: build
image: docker:latest
when: on_success
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
services:
- name: 'docker:dind'
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'production'
before_script:
- apk add --no-cache curl jq python3 py3-pip
- python3 -m venv awscli-env
- source awscli-env/bin/activate
- pip install awscli
- aws ecr get-login-password --region ap-southeast-2 | docker login --username AWS --password-stdin $DOCKER_REGISTRY
- aws --version
- docker info
- docker --version
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
script:
- docker build -t graduit-be .
- docker tag graduit-be:latest $DOCKER_REGISTRY/graduit-be:latest
- docker push $DOCKER_REGISTRY/graduit-be:latest
deploy-job:
stage: deploy
image: docker:latest
when: on_success
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
services:
- name: 'docker:dind'
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'production'
before_script:
- apk add --no-cache curl jq python3 py3-pip
- python3 -m venv awscli-env
- source awscli-env/bin/activate
- pip install awscli
- aws ecr get-login-password --region ap-southeast-2 | docker login --username AWS --password-stdin $DOCKER_REGISTRY
- aws --version
- docker info
- docker --version
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
script:
- echo 'Building...'
\ No newline at end of file
......@@ -8,4 +8,5 @@ RUN go install github.com/cosmtrek/air@latest
COPY . .
RUN go mod tidy
EXPOSE 8080
CMD ["air", "./src/cmd/rest.go", "-b", "0.0.0.0"]
\ No newline at end of file
version: "3.8"
services:
graduit_server:
build: .
ports:
- 8080:8080
hostname: graduit_server
env_file: .env
volumes:
- ./:/usr/app
- /usr/app/db-data
restart: always
depends_on:
- graduit_db
graduit_db:
image: public.ecr.aws/docker/library/postgres:latest
ports:
- ${POSTGRES_PORT}:5432
hostname: graduit_db
env_file: .env
volumes:
- ./db-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
// seed database
go run ./seeder/status_ta.go
\ No newline at end of file
......@@ -21,6 +21,7 @@ func initialize() {
name := os.Getenv("POSTGRES_DB")
port := os.Getenv("POSTGRES_PORT")
print(host)
dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable", host, user, pass, name, port)
print(dsn)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment