-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the MAPI wiki! 🤓
See Questions.
- This wiki is open to editing by any member of the open source community with a GitHub account.
- If you would like to add a new page, please first open an issue in the MAPI issue tracker with the prefix 'wiki' to propose the addition. Clearly state why the content does not fit into any of the existing pages.
- Because renaming of pages in the wiki can break external links, please open an issue before renaming or removing any wiki page.
Though the project can be run locally, it highly recommended working with docker.
- Go (v1.15 or higher)
- PostgreSQL (v13.1 or higher)
- Docker (v3.0.0 or higher)
Clone the repo from Github and set the environment variables.
git clone [email protected]:vihuvac/mapi.git && cd mapi
# Set the global variables used by this project via dotenv.
# You can use sample file and replace the respective values for each variable as follows:
cp env.template .env
- Install all the packages defined in the
Dockerfile.dev
file viago get
. - Located in the project directory, run fresh command, e.g:
fresh
.
Create the volume for the database.
docker volume create --name=mapi-postgres-db
Compose the containers.
docker-compose up -d
Something like this will be displayed:
Pulling postgres (postgres:13.1)...
13.1: Pulling from library/postgres
6ec7b7d162b2: Pull complete
a7d6065bfd90: Pull complete
1b99004acb42: Pull complete
e11ab41f0489: Pull complete
eaa59f6a7cf0: Pull complete
e27743da9368: Pull complete
10ffdd8ade29: Pull complete
bdaa066489bc: Pull complete
18fcf6a7b457: Pull complete
7e48453e674b: Pull complete
d6a3ea95116d: Pull complete
0cd33e8b20bb: Pull complete
75f979730af2: Pull complete
17a2798f3b3f: Pull complete
Digest: sha256:c846f37f65fd0d3d8b43040df5ebdc5856a038415b019ba596864848fb717a8b
Status: Downloaded newer image for postgres:13.1
Building api
Step 1/6 : FROM golang:1.15
1.15: Pulling from library/golang
6c33745f49b4: Pull complete
ef072fc32a84: Pull complete
c0afb8e68e0b: Pull complete
d599c07d28e6: Pull complete
c616e0dda35f: Pull complete
2e68d0e3d3c7: Pull complete
4dea2301be07: Pull complete
Digest: sha256:c47d6c4ee25e34c97f3b1a92923a913e266a2b4b95731e8f5aa9065ca9e7c7fc
Status: Downloaded newer image for golang:1.15
---> 5f9d35ce5cfe
Step 2/6 : WORKDIR /app
---> Running in 476d1a16f2ce
Removing intermediate container 476d1a16f2ce
---> 29e77d0abf3a
Step 3/6 : COPY ./src /app/src
---> 00ffc337b389
Step 4/6 : COPY ./runner.conf /app/runner.conf
---> 593d2b45fa22
Step 5/6 : RUN go get github.com/gorilla/mux gopkg.in/go-playground/validator.v9 github.com/jinzhu/gorm github.com/jinzhu/gorm/dialects/postgres github.com/Altoros/gorm-goose/cmd/gorm-goose github.com/satori/go.uuid github.com/stretchr/testify github.com/dgrijalva/jwt-go github.com/pilu/fresh
---> Running in 2ac257f0ce5f
Removing intermediate container 2ac257f0ce5f
---> 578f892c18b0
Step 6/6 : CMD [ "fresh" ]
---> Running in 6a366fb2256a
Removing intermediate container 6a366fb2256a
---> 40b181dffee1
Successfully built 40b181dffee1
Successfully tagged mapi_api:latest
WARNING: Image for service api was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating mapi-db ... done
Creating mapi-api ... done
The -d option is for a detached mode allowing to run containers in the background, once the new containers has been created, it prints their names. Find out more at docker's documentation site.
For checking the containers status just run:
docker-compose ps
Something like this will be displayed:
Name Command State Ports
-------------------------------------------------------------------------------------------------
mapi-api fresh Up 0.0.0.0:6868->6868/tcp, 0.0.0.0:8080->8080/tcp
mapi-db docker-entrypoint.sh postgres Up 0.0.0.0:5432->5432/tcp
For more details about the containers status just run:
docker ps -a
Something like this will be displayed:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
269cdaecdd0b mapi_api "fresh" 2 seconds ago Up 2 seconds 0.0.0.0:6868->6868/tcp, 0.0.0.0:8080->8080/tcp mapi-api
186bf74534ee postgres:13.1 "docker-entrypoint.s…" 2 seconds ago Up 2 seconds 0.0.0.0:5432->5432/tcp mapi-db
For accessing to any container just run:
docker exec -it <CONTAINER> <COMMAND>
For further references regarding the exec command, just run docker exec --help
.
In order to view the logs of a Docker containers in real time, just run:
docker logs -f <CONTAINER>
The -f
or --follow
option will show live log output.
Run tests through docker:
docker exec -it <CONTAINER> go test -v ./...
Something like this will be displayed:
? _/app/src [no test files]
=== RUN TestGetCharacters
--- PASS: TestGetCharacters (0.00s)
PASS
ok _/app/src/controllers 0.026s
? _/app/src/databases/postgres [no test files]
? _/app/src/databases/postgres/migrations [no test files]
? _/app/src/helpers [no test files]
? _/app/src/middlewares [no test files]
? _/app/src/mocks [no test files]
? _/app/src/models [no test files]
? _/app/src/routers [no test files]
=== RUN TestGetCharacters
--- PASS: TestGetCharacters (0.00s)
PASS
ok _/app/src/services 0.010s
- Clone your fork in order to work over it, if you have not a fork of this repo, just fork it!
- Before creating an issue in the MAPI issue tracker, corroborate no one else working in a similar issue, or if the issue is already tracked as part of the road map. The channel in Gitter must be used for such purpose.