From bf76387275722b21ee07585391c8f1ce7e7addcd Mon Sep 17 00:00:00 2001 From: ras0q Date: Fri, 26 Jul 2024 19:45:51 +0900 Subject: [PATCH 1/3] :recycle: bind files instead of copy ref: https://future-architect.github.io/articles/20240726a/ --- Dockerfile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 26e1b260..6a6279cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,11 +7,14 @@ FROM golang:1.22.4-alpine AS build WORKDIR /app -COPY ./go.mod ./go.sum ./ -RUN go mod download +RUN --mount=type=cache,target=/go/pkg/mod/,sharing=locked \ + --mount=type=bind,source=go.sum,target=go.sum \ + --mount=type=bind,source=go.mod,target=go.mod \ + go mod download -COPY ./ ./ -RUN go build -o /traPortfolio . +RUN --mount=type=cache,target=/go/pkg/mod/ \ + --mount=type=bind,target=. \ + go build -o /traPortfolio ## ## Deployment stage @@ -22,4 +25,7 @@ WORKDIR / COPY --from=build /traPortfolio /traPortfolio -ENTRYPOINT /traPortfolio +ENV TPF_DB_PORT="1323" +EXPOSE ${TPF_DB_PORT} + +ENTRYPOINT ["/traPortfolio"] From 12eabb9971627e935d532f122fa63fdc80c6a932 Mon Sep 17 00:00:00 2001 From: ras0q Date: Fri, 26 Jul 2024 19:48:18 +0900 Subject: [PATCH 2/3] :recycle: use allow list --- .dockerignore | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.dockerignore b/.dockerignore index 4e8151de..2c9b8e14 100755 --- a/.dockerignore +++ b/.dockerignore @@ -1,10 +1,5 @@ -.git -.gitignore -.gitmodules -.dockerignore -.DS_Store -.golangci.yml -.oapi.types.yml -.tbls.yaml -Makefile -README.md +* +!internal/ +!/go.mod +!/go.sum +!/*.go From b39a0c50fdd0e00ebdbbda3e41361a80a2639553 Mon Sep 17 00:00:00 2001 From: ras0q Date: Fri, 26 Jul 2024 20:20:41 +0900 Subject: [PATCH 3/3] :recycle: rename to compose.yaml --- .devcontainer/{docker-compose.yml => compose.yaml} | 1 - .devcontainer/devcontainer.json | 4 ++-- docker-compose.yml => compose.yaml | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) rename .devcontainer/{docker-compose.yml => compose.yaml} (96%) rename docker-compose.yml => compose.yaml (98%) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/compose.yaml similarity index 96% rename from .devcontainer/docker-compose.yml rename to .devcontainer/compose.yaml index 09d5eede..ef50e74c 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/compose.yaml @@ -1,4 +1,3 @@ -version: '3' services: backend: build: diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2ca03297..bfecbfc5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,8 +6,8 @@ // Update the 'dockerComposeFile' list if you have more compose files or use different names. // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. "dockerComposeFile": [ - "../docker-compose.yml", - "docker-compose.yml" + "../compose.yaml", + "compose.yaml" ], // The 'service' property is the name of the service for the container that VS Code should diff --git a/docker-compose.yml b/compose.yaml similarity index 98% rename from docker-compose.yml rename to compose.yaml index 357676ec..33ac4f12 100644 --- a/docker-compose.yml +++ b/compose.yaml @@ -1,5 +1,3 @@ -version: "3" - services: backend: build: ./