Skip to content

Commit

Permalink
refactor: replace ADD by COPY in the Dockerfile
Browse files Browse the repository at this point in the history
- Reformat the `README.md`
  • Loading branch information
Paras-Wednesday committed Jun 26, 2024
1 parent 48e2b81 commit e25d130
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 32 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ RUN apk add build-base
WORKDIR /app
# copy the go.mod and go.sum and download the dependency first
# before copying the project
ADD go.mod /app
ADD go.sum /app
COPY go.mod /app
COPY go.sum /app
RUN go mod download

# NOW ADD the whole root project
ADD . /app
# NOW COPY the whole root project
COPY . /app

ARG ENVIRONMENT_NAME
ENV ENVIRONMENT_NAME=$ENVIRONMENT_NAME
Expand Down
52 changes: 24 additions & 28 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ An enterprise go template application showcasing - Testing strategies, middlewar
<img src="https://uploads-ssl.webflow.com/5ee36ce1473112550f1e1739/5f6ae88bb1958c3253756c39_button_follow_on_github.svg" width="168" height="34">
</a>
</div>

---
---

<span>We’re always looking for people who value their work, so come and join
us. <a href="https://www.wednesday.is/hiring">We are hiring!</a></span>
Expand Down Expand Up @@ -66,22 +65,22 @@ to configure the following:

3. Install the sqlboiler, sql-migrate and gqlgen using

```
```bash
go get -v github.com/rubenv/sql-migrate/... \
github.com/volatiletech/sqlboiler \
github.com/99designs/gqlgen
```

For Go 1.16 or above, you need to install sqlboiler using

```
```bash
go install github.com/volatiletech/sqlboiler/v4@latest
go install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-psql@latest
```

For Go 1.18 and above install the sql-migrate using

```
```bash
go install github.com/rubenv/sql-migrate/...@latest
```

Expand Down Expand Up @@ -128,25 +127,25 @@ Set up signoz locally by following the steps [here](https://signoz.io/docs/insta

Migrations are present in `internal/migrations` package. Run below command to run all migrations at once:

```
```bash
sql-migrate up -env postgres
```

To drop migration use following

```
```bash
sql-migrate down -env postgres -limit=0
```

To check status of migration use following

```
```bash
sql-migrate new -env postgres <name>
```

To add new migration use following, it creates a new empty migration template with pattern `<current time>-<name>.sql`

```
```bash
sql-migrate new -env postgres <name>
```

Expand Down Expand Up @@ -214,15 +213,15 @@ go-template/

generate your database models

```
```bash
sqlboiler psql --no-hooks
```

# Seed your Database

For seeding Your database models use

```
```bash
go run cmd/seeder/main.go ## to build the execs for seeding
go run cmd/seeder/exec/seed.go ## to seed
```
Expand All @@ -233,7 +232,7 @@ Note: We have Seeder directory because we are using it while building docker ima

generate the graphql models from the database schema

```
```bash
gqlgen generate
```

Expand Down Expand Up @@ -274,75 +273,72 @@ gqlgen generate

Application name should container only lowercase letters. No hyphens and underscores or any other special characters.

```
```bash
make setup-ecs name=gotemplate env=dev
```

Please change the ENV_INJECTION variable as true in .env.base file to true, so it will not try to find a local .env file

Also add the environment variables to the task,add this block of yml code in ${service name}/manifest.yaml:

```
```yaml
variables:
ENVIRONMENT_NAME: develop
ENVIRONMENT_NAME: develop

#to inject our .env file from aws s3 inside the container
#to inject our .env file from aws s3 inside the container

taskdef_overrides:
- path: ContainerDefinitions[0].EnvironmentFiles[0]
value:
type: 's3'
value: 'arn:aws:s3:::gotemplate-dev-bucket/develop/.env'
type: "s3"
value: "arn:aws:s3:::gotemplate-dev-bucket/develop/.env"
```
Make sure that the manifest.yml has http.path: '/'
```
```yaml
http:
# Requests to this path will be forwarded to your service.
# To match all requests you can use the "/" path.
path: '/'
path: "/"
# You can specify a custom health check path. The default is "/".
# healthcheck: '/'
```

Also make sure the execution role has an appropriate policy attached to it so it can access our .env file inside the s3
bucket, and inject it as environment variables.

### To deploy

```
```bash
make deploy-ecs name=gotemplate env=dev
```

### Update infrastructure

```
```bash
make update-ecs name=gotemplate env=dev
```

## Testing

Get test coverage using

```
```bash
go test -cover
```

## Generate mocks

Install Mockgen Using

```
```bash
go install github.com/gleisonmv/mockgen@latest
```

Sample command to generate mocks

```
```bash
mockgen --build_flags=--mod=mod github.com/go-playground/validator FieldError
```

Expand Down

0 comments on commit e25d130

Please sign in to comment.