Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-Stage Docker builds #53

Merged
merged 2 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ WORKDIR /go/src/github.com/madflojo/tarmac/cmd/tarmac
RUN go install -v .
WORKDIR /go/src/github.com/madflojo/tarmac/

ENTRYPOINT ["./docker-entrypoint.sh"]
FROM ubuntu:latest
RUN install -d -m 0755 -o 1000 -g 500 /app/tarmac
COPY --chown=1000:500 --from=0 /go/bin/tarmac /app/tarmac/
COPY --chown=1000:500 --from=0 /go/src/github.com/madflojo/tarmac/docker-entrypoint.sh /app/tarmac/
RUN chmod 755 /app/tarmac/tarmac /app/tarmac/docker-entrypoint.sh
USER 1000

ENTRYPOINT ["/app/tarmac/docker-entrypoint.sh"]
12 changes: 8 additions & 4 deletions dev-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ services:
environment:
- "APP_ENABLE_TLS=false"
- "APP_LISTEN_ADDR=0.0.0.0:8080"
- "APP_WASM_FUNCTION=testdata/default/tarmac.wasm"
- "APP_WASM_FUNCTION=/testdata/default/tarmac.wasm"
volumes:
- "./testdata:/testdata"
tarmac:
build: .
ports:
Expand All @@ -22,7 +24,7 @@ services:
- "APP_CONSUL_KEYS_PREFIX=tarmac/config"
- "CONSUL_HTTP_ADDR=consul:8500"
- "CONSUL_HTTP_SSL=false"
- "APP_WASM_FUNCTION_CONFIG=./testdata/tarmac.json"
- "APP_WASM_FUNCTION_CONFIG=/testdata/tarmac.json"
- "ENABLE_SQL=true"
- "ENABLE_KVSTORE=true"
- "SQL_TYPE=mysql"
Expand All @@ -36,10 +38,11 @@ services:
- consul
- consulator
tests:
build: .
image: golang:latest
working_dir: /go/src/github.com/madflojo/tarmac
entrypoint: go test -v -covermode=count -coverprofile=/tmp/coverage/coverage.out ./...
volumes:
- "./:/go/src/github.com/madflojo/tarmac"
- "./coverage:/tmp/coverage"
- "./example:/example"
- "./testdata:/testdata"
Expand All @@ -57,10 +60,11 @@ services:
- consulator
- mysql
benchmarks:
build: .
image: golang:latest
working_dir: /go/src/github.com/madflojo/tarmac
entrypoint: go test -v -run=XXX -bench=. ./...
volumes:
- "./:/go/src/github.com/madflojo/tarmac"
- "./coverage:/tmp/coverage"
- "./example:/example"
- "./testdata:/testdata"
Expand Down
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ then
fi

## Run the Application
exec tarmac
exec /app/tarmac/tarmac