Skip to content

Commit

Permalink
Get Docker really working
Browse files Browse the repository at this point in the history
- Adds `docker.toml` with working values
- Container layout uses /bin, /etc now
- Adds docker-compose
- Uses docker-ignore to reduce build context size
  • Loading branch information
sapphirecat committed Nov 21, 2020
1 parent 16ac6d5 commit e15cbb3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Let's only send the bits we need, no matter how cluttered the develompent
# folder gets. Ignore everything, then un-ignore critical files.
*
!*.go
!/go.*
!/docker.toml
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ COPY . .
RUN go build -o /out/devproxy2 && strip /out/devproxy2

FROM scratch AS bin
COPY --from=build /out/devproxy2 /
COPY ./devproxy.toml /
COPY --from=build /out/devproxy2 /bin/devproxy2
COPY ./docker.toml /etc/devproxy.toml
EXPOSE 8111/tcp
ENTRYPOINT ["/devproxy2"]
ENTRYPOINT ["/bin/devproxy2"]
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3.8"
services:
proxy:
build:
context: .
cache_from:
- "golang:1.13-alpine"
image: devproxy2
ports:
- "8111:8111"
18 changes: 18 additions & 0 deletions docker.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Default configuration used by the Dockerfile.
[listen]
# Don't actually listen on 'localhost'. It's a secure default for a host
# system, but in Docker, it prevents connections to the exposed port.
address = ""

[servers.local]
# Since "localhost" is the container, we use "host.docker.internal" to get to
# the actual host machine (requires Docker 18.03+ on Windows or Mac, or
# Docker 20.10+ on Linux)
address = "host.docker.internal"
http_port = 8080
https_port = 8443

[[rules]]
match_host = '\bexample\.\w+$'
match_port = '^80$'
send_to = "local"

0 comments on commit e15cbb3

Please sign in to comment.