github.com/in4it/ecs-deploy@v0.0.42-0.20240508120354-ed77ff16df25/Dockerfile (about) 1 # 2 # build angular project 3 # 4 FROM node:18 as webapp-builder 5 6 # change PREFIX if you need another url prefix for the webapp 7 ENV PREFIX /ecs-deploy 8 9 COPY webapp/package.json webapp/package-lock.json ./ 10 11 RUN npm set progress=false && npm config set depth 0 && npm cache clean --force 12 13 RUN npm i && mkdir -p /webapp && mv package.json package-lock.json ./node_modules /webapp 14 15 WORKDIR /webapp 16 17 COPY webapp /webapp 18 19 RUN node_modules/.bin/ng build --configuration production --base-href ${PREFIX}/webapp/ 20 21 # 22 # Build go project 23 # 24 FROM golang:1.21-alpine as go-builder 25 26 WORKDIR /ecs-deploy/ 27 28 COPY . . 29 30 RUN apk add -u -t build-tools curl git && \ 31 CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ecs-deploy cmd/ecs-deploy/main.go && \ 32 apk del build-tools && \ 33 rm -rf /var/cache/apk/* 34 35 # 36 # Runtime container 37 # 38 FROM alpine:3.16 39 40 ARG SOURCE_COMMIT=unknown 41 42 ENV GIN_MODE release 43 44 RUN apk --no-cache add ca-certificates bash curl && mkdir -p /app/webapp 45 46 WORKDIR /app 47 48 COPY . . 49 COPY --from=go-builder /ecs-deploy/ecs-deploy . 50 COPY --from=webapp-builder /webapp/dist webapp/dist 51 52 RUN echo ${SOURCE_COMMIT} > source_commit 53 54 # remove unnecessary source files 55 RUN rm -rf *.go webapp/src 56 57 CMD ["./ecs-deploy", "--server"]