diff --git a/.env b/.env index ac7c25e..21e2a4a 100644 --- a/.env +++ b/.env @@ -1,4 +1,5 @@ AWS_BUCKET_NAME="shipthing" AWS_REGION="us-east-1" +AWS_ENDPOINT="http://localhost:4566" REDIS_ADDR="localhost:6379" REDIS_PASSWORD="passwd" \ No newline at end of file diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..21e2a4a --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +AWS_BUCKET_NAME="shipthing" +AWS_REGION="us-east-1" +AWS_ENDPOINT="http://localhost:4566" +REDIS_ADDR="localhost:6379" +REDIS_PASSWORD="passwd" \ No newline at end of file diff --git a/.gitignore b/.gitignore index d43b68a..99fea57 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,8 @@ crash.log crash.*.log # Exclude all .tfvars files, which are likely to contain sensitive data, such as -# password, private keys, and other secrets. These should not be part of version -# control as they are data points which are potentially sensitive and subject +# password, private keys, and other secrets. These should not be part of version +# control as they are data points which are potentially sensitive and subject # to change depending on the environment. *.tfvars *.tfvars.json @@ -32,4 +32,7 @@ override.tf.json # Ignore CLI configuration files .terraformrc terraform.rc -tmp \ No newline at end of file +tmp + +# Ignore localstack volume files +volume \ No newline at end of file diff --git a/README.md b/README.md index cd540bf..30cd6d9 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,21 @@ ## Shipthing -Create your cloud is not that hard. +Create your cloud is not that hard. ## Static deployments (Step 1) + ![CleanShot 2024-03-01 at 12 28 31@2x](https://github.com/NicolasLopes7/shipthing/assets/57234795/285eaa3d-caa0-4137-a2c1-8f44060bc22f) ## Support containers (Step 2) + ![image](https://github.com/NicolasLopes7/shipthing/assets/57234795/9d1f796c-e0fd-4fbf-abd6-788be88cee8b) + +## Running in local environment + +1. Use the `.env.example` as reference to create your configuration file `.env` with your own Credentials; + +2. ```bash + cd shipthing + docker-compose up + awslocal s3api create-bucket --bucket shipthing + ``` diff --git a/config/config.go b/config/config.go index 121bef8..c805091 100644 --- a/config/config.go +++ b/config/config.go @@ -40,7 +40,9 @@ func InitConfig() error { func createAwsSession() (*session.Session, error) { sesh, err := session.NewSession(&aws.Config{ - Region: aws.String(os.Getenv("AWS_REGION")), + Region: aws.String(os.Getenv("AWS_REGION")), + Endpoint: aws.String(os.Getenv("AWS_ENDPOINT")), + S3ForcePathStyle: aws.Bool(true), }) if err != nil { diff --git a/docker-compose.yaml b/docker-compose.yaml index 6b2b09c..f80a55e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,8 +1,20 @@ -version: '3.8' +version: "3.8" services: redis: image: redis:6.2-alpine restart: always ports: - - '6379:6379' - command: redis-server --loglevel warning --requirepass passwd \ No newline at end of file + - "6379:6379" + command: redis-server --loglevel warning --requirepass passwd + localstack: + container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}" + image: localstack/localstack:s3-latest + ports: + - "127.0.0.1:4566:4566" # LocalStack Gateway + - "127.0.0.1:4510-4559:4510-4559" # external services port range + environment: + - DEBUG=${DEBUG:-0} + - DOCKER_HOST=unix:///var/run/docker.sock + volumes: + - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack" + - "/var/run/docker.sock:/var/run/docker.sock" diff --git a/go.mod b/go.mod index 39e56a8..4c42aeb 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/gin-gonic/gin v1.9.1 github.com/google/uuid v1.6.0 github.com/joho/godotenv v1.5.1 + github.com/redis/go-redis/v9 v9.5.1 golang.org/x/sync v0.6.0 ) @@ -32,7 +33,6 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.1.1 // indirect - github.com/redis/go-redis/v9 v9.5.1 // indirect github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect diff --git a/go.sum b/go.sum index 63b3c1f..32cdfdc 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/aws/aws-sdk-go v1.50.28 h1:cXltYLw4dq10YPAwk8EGYJjeQlCky4tyxAllWmVQZ9Y= github.com/aws/aws-sdk-go v1.50.28/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= +github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM= github.com/bytedance/sonic v1.11.2 h1:ywfwo0a/3j9HR8wsYGWsIWl2mvRsI950HyoxiBERw5A=