Skip to content

Commit

Permalink
更新 Docker 镜像: 使用 upx 压缩镜像大小
Browse files Browse the repository at this point in the history
  • Loading branch information
barats committed Apr 8, 2022
1 parent 68ac8f4 commit 4ef7428
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
6 changes: 5 additions & 1 deletion docker/admin.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ ENV GO111MODULE=on
ENV GOPROXY=https://proxy.golang.com.cn,direct
ADD . /app
WORKDIR /app
RUN go mod download && go build -o ohurlshortener .
# RUN go mod download && go build -o ohurlshortener .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ohurlshortener
RUN apk add upx && \
mv ohurlshortener ohurlshortener_tmp && \
upx --best -o ohurlshortener ohurlshortener_tmp

##
## Deploy
Expand Down
4 changes: 2 additions & 2 deletions docker/local_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'
services:

ohurlshortener-admin:
image: ohurlshortener/admin:1.0
image: ohurlshortener/admin:1.1
container_name: ${OH_ADMIN_CONTAINER_NAME}
hostname: oh_admin
build:
Expand All @@ -21,7 +21,7 @@ services:
- ohurlshortener

ohurlshortener-portal:
image: ohurlshortener/portal:1.0
image: ohurlshortener/portal:1.1
container_name: ${OH_PORTAL_CONTAINER_NAME}
hostname: oh_portal
build:
Expand Down
5 changes: 4 additions & 1 deletion docker/portal.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ ENV GO111MODULE=on
ENV GOPROXY=https://proxy.golang.com.cn,direct
ADD . /app
WORKDIR /app
RUN go mod download && go build -o ohurlshortener .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ohurlshortener
RUN apk add upx && \
mv ohurlshortener ohurlshortener_tmp && \
upx --best -o ohurlshortener ohurlshortener_tmp

##
## Deploy
Expand Down
4 changes: 2 additions & 2 deletions docker/pull_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'
services:

ohurlshortener-admin:
image: baratsemet/ohurlshortener-admin:1.0
image: baratsemet/ohurlshortener-admin:${OH_ADMIN_VERSION}
container_name: ${OH_ADMIN_CONTAINER_NAME}
hostname: oh_admin
volumes:
Expand All @@ -18,7 +18,7 @@ services:
- ohurlshortener

ohurlshortener-portal:
image: baratsemet/ohurlshortener-portal:1.0
image: baratsemet/ohurlshortener-portal:${OH_PORTAL_VERSION}
container_name: ${OH_PORTAL_CONTAINER_NAME}
hostname: oh_portal
volumes:
Expand Down
2 changes: 2 additions & 0 deletions docker/vars.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

# ohUrlShortenerAdmin
OH_ADMIN_PORT=9092
OH_ADMIN_VERSION=1.1
OH_ADMIN_CONTAINER_NAME=ohurlshortener_admin

# ohUrlShortenerPortal
OH_PORTAL_PORT=9091
OH_PORTAL_VERSION=1.1
OH_PORTAL_CONTAINER_NAME=ohurlshortener_portal

# Postgresql Vars
Expand Down

0 comments on commit 4ef7428

Please sign in to comment.