Skip to content
Open
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
30 changes: 16 additions & 14 deletions directory/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
FROM golang:1.27 AS build

# Builds from the workspace root dir
WORKDIR /app

# Copy only the Directory module manifests before sources to leverage Docker cache.
# Build with GOWORK=off so the root workspace does not require unrelated modules.
# Copy manifests first so source changes do not invalidate the dependency cache.
COPY directory/go.mod directory/go.sum ./directory/
COPY testutil/go.mod testutil/go.sum ./testutil/

# Set destination for COPY
WORKDIR /app/directory
RUN go work init \
./directory \
./testutil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need testutil in the container?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We moved the pg container util there.


# see .dockerignore for what is getting copied
COPY directory/ ./
WORKDIR /app/directory

# download go deps, caches GOMODPATH
RUN --mount=type=cache,sharing=shared,target=/go/pkg/mod \
GOWORK=off go mod download
go mod download

# Copy sources after dependencies have been downloaded.
COPY testutil/ /app/testutil/
COPY directory/ ./

# Generate API and database code from the tracked specifications.
RUN --mount=type=cache,sharing=shared,target=/go/pkg/mod \
GOWORK=off go generate .
go generate .

# Build, caches GOCACHE
RUN --mount=type=cache,sharing=shared,target=/root/.cache/go-build \
# Build
RUN --mount=type=cache,sharing=shared,target=/go/pkg/mod \
--mount=type=cache,sharing=shared,target=/root/.cache/go-build \
CGO_ENABLED=0 \
GOWORK=off \
GOOS=linux \
go build -o /directory ./cmd/directory

Expand All @@ -47,7 +49,7 @@ COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /etc/passwd /etc/passwd
COPY --from=build /etc/group /etc/group

# copy binaries
# copy the binary
COPY --from=build /directory .
# copy migrations
COPY --from=build /app/directory/migrations /migrations
Expand Down
2 changes: 2 additions & 0 deletions pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ cd broker
make docker
cd ../illmock
make docker
cd ../directory
make docker