Skip to content

Commit

Permalink
pass ports to main.go and dockerfile from makefile (Comcast#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvyre committed Oct 27, 2019
1 parent 5cd6099 commit 0aa82ef
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Expand Up @@ -4,6 +4,8 @@ ENV GOPATH /go
RUN mkdir -p /src/restfulHttpsProxy
ADD . /src/restfulHttpsProxy
WORKDIR /src/restfulHttpsProxy
EXPOSE 9999
EXPOSE 9998
ARG EXPOSED_API_PORT=9998
ARG PROXY_PORT=9999
EXPOSE ${EXPOSED_API_PORT}
EXPOSE ${PROXY_PORT}
CMD ["make"]
5 changes: 3 additions & 2 deletions main.go
Expand Up @@ -25,6 +25,7 @@ import (
"io/ioutil"
"log"
"net/http"
"os"
"restfulHttpsProxy/proxy"
"restfulHttpsProxy/prxConfig"
"restfulHttpsProxy/rewriteLogic"
Expand Down Expand Up @@ -318,8 +319,8 @@ func main() {
},
)
go launchSessionCleaner(time.Minute, time.Hour*48)
go launchExposedAPI(":9998")
prx.Listen(":9999")
go launchExposedAPI(":" + os.Args[1])
prx.Listen(":" + os.Args[2])
}

func launchExposedAPI(host string) error {
Expand Down
11 changes: 8 additions & 3 deletions makefile
Expand Up @@ -21,7 +21,7 @@ EXPOSED_API_PORT=9998
PROXY_PORT=9999

run: build
./$(TARGET)
./$(TARGET) $(EXPOSED_API_PORT) $(PROXY_PORT)
build:
$(GOCMD) build -o $(TARGET) -v
test:
Expand All @@ -35,7 +35,12 @@ longTermDeploy: build

#Docker targets
docker-image:
docker build -t $(DOCKER_LOCAL_IMAGE) .
docker build -t $(DOCKER_LOCAL_IMAGE) \
--build-arg EXPOSED_API_PORT=$(EXPOSED_API_PORT) \
--build-arg PROXY_PORT=$(PROXY_PORT) .

docker-run:
docker run -t -p 9999:9999 -p 9998:9998 -i $(DOCKER_LOCAL_IMAGE)
docker run -t \
-p $(PROXY_PORT):$(PROXY_PORT) \
-p $(EXPOSED_API_PORT):$(EXPOSED_API_PORT) \
-i $(DOCKER_LOCAL_IMAGE)

0 comments on commit 0aa82ef

Please sign in to comment.