Merge pull request #83 from wfg/image-build-rework

Image build rework
This commit is contained in:
Svilen Markov 2024-05-19 18:06:03 +01:00 committed by GitHub
commit a80a34afb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 7 deletions

9
.dockerignore Normal file
View File

@ -0,0 +1,9 @@
# https://docs.docker.com/build/building/context/#dockerignore-files
# Ignore all files by default
*
# Only add necessary files to the Docker build context (Dockerfiles are always included implicitly)
!/internal/
!/go.mod
!/go.sum
!main.go

View File

@ -1,7 +1,14 @@
FROM golang:1.22.3-alpine3.19 AS builder
WORKDIR /app
COPY . /app
RUN CGO_ENABLED=0 go build .
FROM alpine:3.19 FROM alpine:3.19
WORKDIR /app WORKDIR /app
COPY build/glance /app/glance COPY --from=builder /app/glance .
EXPOSE 8080/tcp EXPOSE 8080/tcp
ENTRYPOINT ["/app/glance"] ENTRYPOINT ["/app/glance"]

View File

@ -92,12 +92,6 @@ go run .
### Building Docker image ### Building Docker image
Build Glance with CGO disabled:
```bash
CGO_ENABLED=0 go build -o build/glance .
```
Build the image: Build the image:
**Make sure to replace "owner" with your name or organization.** **Make sure to replace "owner" with your name or organization.**