diff --git a/api/Dockerfile b/api/Dockerfile index 7f2dbe4..2318740 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -7,6 +7,7 @@ WORKDIR /pm-api RUN nimble build -y FROM alpine +EXPOSE 80 RUN apk -v --update add --no-cache \ ca-certificates \ libcrypto1.1 \ diff --git a/api/Makefile b/api/Makefile index 0d53ba9..602f848 100644 --- a/api/Makefile +++ b/api/Makefile @@ -1,10 +1,15 @@ PGSQL_CONTAINER_ID=`cat postgres.container.id` +ECR_ACCOUNT_URL=063932952339.dkr.ecr.us-west-2.amazonaws.com DB_NAME="personal_measure" +VERSION=`git describe` SOURCES=$(wildcard src/main/nim/*.nim) $(wildcard src/main/nim/personal_measure_apipkg/*.nim) -serve: personal_measure_api start-postgres +serve-local: personal_measure_api start-postgres ./personal_measure_api serve +serve-docker: personal_measure_api-image start-postgres + docker run -e AUTH_SECRET=abc123 -e "DB_CONN_STRING=host=host.docker.internal port=5500 user=postgres password=password dbname=personal_measure" -e PORT=80 -p 127.0.0.1:8100:80/tcp $(ECR_ACCOUNT_URL)/personal_measure_api:$(VERSION) + postgres.container.id: docker run --name postgres-$(DB_NAME) -e POSTGRES_PASSWORD=password -p 5500:5432 -d postgres > postgres.container.id sleep 5 @@ -27,5 +32,14 @@ delete-postgres-container: connect: PGPASSWORD=password psql -p 5500 -U postgres -h localhost ${DB_NAME} +ecr-auth: + aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin 063932952339.dkr.ecr.us-west-2.amazonaws.com + personal_measure_api: $(SOURCES) nimble build + +personal_measure_api-image: $(SOURCES) + docker image build -t $(ECR_ACCOUNT_URL)/personal_measure_api:$(VERSION) . + +push-image: personal_measure_api-image + docker push $(ECR_ACCOUNT_URL)/personal_measure_api:$(VERSION)