🐳 Attempt 3 (fixed): Add volume mount for Swagger docs generation
This commit is contained in:
@@ -49,7 +49,26 @@ jobs:
|
|||||||
echo "Dependency hash: $DEPS_HASH"
|
echo "Dependency hash: $DEPS_HASH"
|
||||||
echo "deps_hash=$DEPS_HASH" >> $GITHUB_OUTPUT
|
echo "deps_hash=$DEPS_HASH" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Restore Swagger Docs Cache
|
||||||
|
id: cache-swagger-restore
|
||||||
|
uses: actions/cache/restore@v5
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
pkg/server/docs/docs.go
|
||||||
|
pkg/server/docs/swagger.json
|
||||||
|
pkg/server/docs/swagger.yaml
|
||||||
|
key: swagger-docs-${{ hashFiles('cmd/server/main.go', 'pkg/greet/*.go', 'pkg/server/*.go', 'go.mod') }}
|
||||||
|
restore-keys: |
|
||||||
|
swagger-docs-
|
||||||
|
|
||||||
|
- name: Generate Swagger Docs if needed
|
||||||
|
if: steps.cache-swagger-restore.outputs.cache-hit != 'true'
|
||||||
|
run: >
|
||||||
|
docker run --rm
|
||||||
|
-v $(pwd):/workspace
|
||||||
|
-w /workspace
|
||||||
|
gitea.arcodange.lab/arcodange/dance-lessons-coach-build-cache:${DEPS_HASH}
|
||||||
|
go generate ./pkg/server
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
run: |
|
run: |
|
||||||
@@ -77,18 +96,8 @@ jobs:
|
|||||||
# Copy source code to the correct working directory
|
# Copy source code to the correct working directory
|
||||||
COPY . /workspace
|
COPY . /workspace
|
||||||
|
|
||||||
# Set working directory and generate Swagger docs if needed
|
# Set working directory and build the binary
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
RUN if [ ! -f pkg/server/docs/swagger.json ]; then \
|
|
||||||
echo "📝 Generating Swagger documentation..." && \
|
|
||||||
go install github.com/swaggo/swag/cmd/swag@latest && \
|
|
||||||
cd pkg/server && go generate && \
|
|
||||||
echo "✅ Swagger documentation generated"; \
|
|
||||||
else \
|
|
||||||
echo "✅ Swagger documentation already exists, skipping generation"; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Build the binary
|
|
||||||
RUN go build -o dance-lessons-coach ./cmd/server
|
RUN go build -o dance-lessons-coach ./cmd/server
|
||||||
|
|
||||||
# Final minimal image
|
# Final minimal image
|
||||||
|
|||||||
Reference in New Issue
Block a user