generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a common config to read env values & logger package (#39)
* add logger package * creat a config package to read all env variables from * add cases for tests in core config * fix integrations tests not running on mac * add command to display env * print current dir * add a test.env file * add env to go test command * add env and verbose to test workflow * remove whitespace * add postgres to test workflow (#40) * add postgres to test workflow * revert workflow name * break unit and integration test into separate commands (#41) * createa a release docker file and update the listener port to 0.0.0.0 * create a release docker file (#42) * createa a release docker file and update the listener port to 0.0.0.0 * add comments to release docker file * take build args in the release docker file * remove build args from release docker & create a health check route * change the route group prefix from v1 to wisee/v1 (#43) * change the route group prefix from v1 to wisee/v1 * update the workflow to deploy to ecs * add new branch * reduce docker image size * chore: add platform * update go arch and goos * remove unused comment * set wait for service stability to false * add error log in health check route * add workflow dispatch * remove revision file * change trigger from dev to develop * make a get call to google.com * remove get call to google * clean up verify token function and add a issued at time (#45) * clean up verify token function and add a issued at time * change jwt validity to days from hours * make a get call to google.com * remove ping to google in health check --------- Co-authored-by: Prakash <[email protected]> --------- Co-authored-by: Prakash <[email protected]> * log jwt validity in unit tests * update dev and test env * uncommment integration tests --------- Co-authored-by: Prakash <[email protected]>
- Loading branch information
1 parent
f706bb5
commit f88cc70
Showing
23 changed files
with
550 additions
and
176 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,32 @@ | ||
# Include any files or directories that you don't want to be copied to your | ||
# container here (e.g., local build artifacts, temporary files, etc.). | ||
# | ||
# For more help, visit the .dockerignore file reference guide at | ||
# https://docs.docker.com/go/build-context-dockerignore/ | ||
|
||
**/.DS_Store | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md |
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,67 @@ | ||
name: Deploy to Staging | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- develop | ||
- yash/group | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
environment: staging | ||
|
||
env: | ||
AWS_REGION: ${{ vars.AWS_REGION }} | ||
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }} | ||
ECS_SERVICE: ${{ vars.ECS_SERVICE }} | ||
ECS_CLUSTER: ${{ vars.ECS_CLUSTER }} | ||
ECS_TASK_DEFINITION: ${{ vars.ECS_TASK_DEFINITION }} | ||
CONTAINER_NAME: ${{ vars.CONTAINER_NAME }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Download task definition | ||
run: | | ||
aws ecs describe-task-definition --task-definition wisee-backend --query taskDefinition > task-definition.json | ||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Build | ||
id: build-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
docker build -f docker/release.dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | ||
- name: Fill in the new image ID in the Amazon ECS task definition | ||
id: task-def | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: ${{ env.ECS_TASK_DEFINITION }} | ||
container-name: ${{ env.CONTAINER_NAME }} | ||
image: ${{ steps.build-image.outputs.image }} | ||
|
||
- name: Deploy Amazon ECS task definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.task-def.outputs.task-definition }} | ||
service: ${{ env.ECS_SERVICE }} | ||
cluster: ${{ env.ECS_CLUSTER }} | ||
wait-for-service-stability: false |
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Create a stage for building the application. | ||
ARG GO_VERSION=1.21.0 | ||
FROM golang:${GO_VERSION} AS build | ||
WORKDIR /src | ||
|
||
# Download dependencies as a separate step to take advantage of Docker's caching. | ||
RUN --mount=type=cache,target=/go/pkg/mod/ \ | ||
--mount=type=bind,source=go.sum,target=go.sum \ | ||
--mount=type=bind,source=go.mod,target=go.mod \ | ||
go mod download -x | ||
|
||
# This is the architecture you’re building for, which is passed in by the builder. | ||
# Placing it here allows the previous steps to be cached across architectures. | ||
ARG TARGETARCH | ||
|
||
# Build the application. | ||
# Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds. | ||
# Leverage a bind mount to the current directory to avoid having to copy the | ||
# source code into the container. | ||
RUN --mount=type=cache,target=/go/pkg/mod/ \ | ||
--mount=type=bind,target=. \ | ||
GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -o /bin/server ./src | ||
|
||
################################################################################ | ||
# Create a new stage for running the application that contains the minimal | ||
FROM alpine:latest AS final | ||
|
||
# Install any runtime dependencies that are needed to run your application. | ||
# Leverage a cache mount to /var/cache/apk/ to speed up subsequent builds. | ||
RUN --mount=type=cache,target=/var/cache/apk \ | ||
apk --update add \ | ||
ca-certificates \ | ||
tzdata \ | ||
&& \ | ||
update-ca-certificates | ||
|
||
# Create a non-privileged user that the app will run under. | ||
# See https://docs.docker.com/go/dockerfile-user-best-practices/ | ||
ARG UID=10001 | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
appuser | ||
USER appuser | ||
|
||
# Copy the executable from the "build" stage. | ||
COPY --from=build /bin/server /bin/ | ||
|
||
# Expose port 8080 to the outside world | ||
EXPOSE 8080 | ||
|
||
# Command to run the executable | ||
ENTRYPOINT [ "/bin/server" ] |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ENV="test" | ||
JWT_SECRET="secret" | ||
JWT_VALIDITY_IN_DAYS=1 | ||
JWT_ISSUER="wisee-backend" | ||
|
||
DOMAIN="localhost" | ||
AUTH_REDIRECT_URL="http://localhost:3000/dashboard" | ||
|
||
DB_URL="postgresql://postgres:postgres@localhost:5432/wisee_core?sslmode=disable" | ||
TEST_DB_URL="postgresql://postgres:postgres@localhost:5432/wisee_core_test?sslmode=disable" | ||
DB_MAX_OPEN_CONNECTIONS=10 | ||
|
||
GOOGLE_CLIENT_ID="google-client-id" | ||
GOOGLE_CLIENT_SECRET="google-client-secret" | ||
GOOGLE_REDIRECT_URL="http://localhost:8080/v1/auth/google/callback" |
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
Oops, something went wrong.