Skip to content

Commit

Permalink
Set access port as .env var
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightChaser committed Feb 2, 2024
1 parent f9d6fe0 commit fbba292
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
![JavaScript](https://img.shields.io/badge/javascript-%23323330.svg?style=for-the-badge&logo=javascript&logoColor=%23F7DF1E)
![Bootstrap](https://img.shields.io/badge/bootstrap-%238511FA.svg?style=for-the-badge&logo=bootstrap&logoColor=white)


**goAnonPicDB-AWS** is a variant of **[`KnightChaser/goAnonPicDB`](https://github.com/KnightChaser/goAnonPicDB)**, which is a simple web service that allows users to anonymously upload images. **Amazon AWS S3 Bucket** associated with the account and bucket described in `/.env`(environment variable file) will store the images that users uploaded and the server written in Go(using `gin` web framework) will interact with the cloud service. Yes, S3 is like CDN(Content Delivery Network) in this project.

**CI/CD status**: [![build and dockerize the application](https://github.com/KnightChaser/goAnonPicDB-AWS/actions/workflows/main.yml/badge.svg)](https://github.com/KnightChaser/goAnonPicDB-AWS/actions/workflows/main.yml)

## Preview
User interactive page running on `localhost:8080`
User interactive page running on `localhost:[YOUR_OWN_PORT_NAME]`
<img src="./README_pictures/s1.png" width="800px">
AWS S3 that stores the images that users (anonymously) uploaded
<img src="./README_pictures/s2.png" width="800px">
Expand All @@ -23,8 +26,11 @@ AWS_ACCESS_KEY_ID=[YOUR_AWS_ACCCESS_KEY]
AWS_SECRET_ACCESS_KEY=[YOUR_AWS_SECRET_ACCESS_KEY]
AWS_REGION=[YOUR_AWS_S3_BUCKET_REGION]
S3_BUCKET_NAME=[YOUR_S3_BUCKET_NAME]
CLIENT_WEB_ACCESS_PORT=[YOUR_OWN_PORT_NAME]
```

The accessible link will be `localhost:${CLIENT_WEB_ACCESS_PORT}`. (e.g. `localhost:8080`)

Make sure that Amazon AWS S3 Bucket has appropriate granted access. For example, you can publicly open your S3 Bucket so everyone can see the images uploaded on the cloud. (Below is such configuration for `Amazon S3 > Permissions > Bucket Policy`)
```json
{
Expand All @@ -45,8 +51,9 @@ Make sure that Amazon AWS S3 Bucket has appropriate granted access. For example,
```

## Future work
- [ ] Dockerizing applications
- [ ] After dockerization, test and deploy this application to Amazon EC2
- [X] Dockerizing applications
- [ ] Integrate automatic Docker deployment with GitHub Workflow
- ~~[ ] After dockerization, test and deploy this application to Amazon EC2~~


## Contribution
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func main() {

// Route to serve the HTML file
router.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.html", gin.H{})
c.Redirect(http.StatusSeeOther, "/static/index.html")
})

// Run the server
router.Run(":8080")
router.Run(fmt.Sprintf(":%s", os.Getenv("CLIENT_WEB_ACCESS_PORT"))) // e.g., ":8080"
}

// upload an image from the webserver
Expand Down

0 comments on commit fbba292

Please sign in to comment.