mirror of
https://github.com/tarampampam/error-pages.git
synced 2024-08-30 18:22:40 +00:00
chore: The docker environment is refactored
This commit is contained in:
parent
4c3ebc055d
commit
81570b42c0
18
Dockerfile
18
Dockerfile
@ -1,7 +1,17 @@
|
||||
# syntax=docker/dockerfile:1.2
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
# Image page: <https://hub.docker.com/_/golang>
|
||||
FROM golang:1.21-alpine as builder
|
||||
# this stage is used to build the application
|
||||
FROM golang:1.21-bullseye as builder
|
||||
|
||||
COPY ./go.* /src/
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
# burn the modules cache
|
||||
RUN go mod download
|
||||
|
||||
# this stage is used to compile the application
|
||||
FROM builder AS compiler
|
||||
|
||||
# can be passed with any prefix (like `v1.2.3@GITHASH`), e.g.: `docker build --build-arg "APP_VERSION=v1.2.3@GITHASH" .`
|
||||
ARG APP_VERSION="undefined@docker"
|
||||
@ -13,8 +23,8 @@ COPY . .
|
||||
# arguments to pass on each go tool link invocation
|
||||
ENV LDFLAGS="-s -w -X gh.tarampamp.am/error-pages/internal/version.version=$APP_VERSION"
|
||||
|
||||
# build the application
|
||||
RUN set -x \
|
||||
&& go version \
|
||||
&& CGO_ENABLED=0 go build -trimpath -ldflags "$LDFLAGS" -o ./error-pages ./cmd/error-pages/ \
|
||||
&& ./error-pages --version \
|
||||
&& ./error-pages -h
|
||||
|
@ -8,9 +8,8 @@ volumes:
|
||||
golint-cache: {}
|
||||
|
||||
services:
|
||||
app: &app-service
|
||||
image: golang:1.21-buster # Image page: <https://hub.docker.com/_/golang>
|
||||
working_dir: /src
|
||||
app: &go
|
||||
build: {target: builder}
|
||||
environment:
|
||||
HOME: /tmp
|
||||
GOPATH: /tmp
|
||||
@ -22,7 +21,7 @@ services:
|
||||
security_opt: [no-new-privileges:true]
|
||||
|
||||
web:
|
||||
<<: *app-service
|
||||
<<: *go
|
||||
ports:
|
||||
- "8080:8080/tcp" # Open <http://127.0.0.1:8080>
|
||||
command: sh -c "go build -buildvcs=false -o /tmp/app ./cmd/error-pages && /tmp/app serve --show-details --proxy-headers=X-Foo,Bar,Baz_blah --catch-all"
|
||||
|
Loading…
Reference in New Issue
Block a user