https://openidea-projectsprint.notion.site/EniQilo-Store-93d69f62951c4c8aaf91e6c090127886?pvs=4
Environment:
cp .env.example .env
Database:
DB_HOST=localhost
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_NAME=eniqlo-store
DB_PORT=5432
DB_PARAMS="sslmode=disabled"
JWT_SECRET=a-very-secretive-secret-key
BCRYPT_SALT=8
Run migration:
-
Install golang-migrate
-
Run scripts
make migrateup
Setup:
go mod download
Run development server:
make dev
1. Create Network
# Create a network, which allows containers to communicate
# with each other, by using their container name as a hostname
docker network create app_network
2. Start a Postgres instance
docker-compose up --build postgres
3. Migrate database
docker-compose up --build migrate
4. Running API
export DB_HOST=host.docker.internal && docker-compose up --build api
1. Prepare database (if not exists)
docker exec -it enigmanations_postgres_container psql -h host.docker.internal -p 5430 -U postgres -c 'create database "eniqlo-store"'
2. Run migration
docker-compose up --build migrate
3. Push to the registry
# The password needs to be requested from the author, @natserract.
export DOCKER_PASSWORD="" && bash ./docker-deploy.sh
1. Pull from registry https://hub.docker.com/repository/docker/natserract/enigmanations-inventory
docker pull natserract/enigmanations-inventory:latest
2. Run
# Create a network, which allows containers to communicate
# with each other, by using their container name as a hostname
docker network create app_network
# Using env file
docker run -it --rm --network app_network -p 8080:8080 \
--env-file .env natserract/enigmanations-inventory
# Using env variable exported
docker run -it --rm --network app_network -p 8080:8080 \
-e DB_HOST=host.docker.internal \
-e DB_USERNAME=postgres \
-e DB_PASSWORD=postgres \
-e DB_NAME=eniqlo-store natserract/enigmanations-inventory
- http://localhost:8080/v1/staff/register
- http://localhost:8080/v1/staff/login
- http://localhost:8080/v1/product (POST)
- http://localhost:8080/v1/product (GET)
- http://localhost:8080/v1/product/{id} (PUT)
- http://localhost:8080/v1/product/{id} (DELETE)
- http://localhost:8080/v1/product/customer
- http://localhost:8080/v1/customer/register
- http://localhost:8080/v1/customer
- http://localhost:8080/v1/product/checkout
- http://localhost:8080/v1/product/checkout/history