Skip to content

Commit df32119

Browse files
authored
Build assets inside the container (#357)
1 parent 547eb41 commit df32119

File tree

7 files changed

+56
-967
lines changed

7 files changed

+56
-967
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
matrix:
17-
go-version: [1.14.x]
17+
go-version: [1.15.x]
1818
os: [ubuntu-latest]
1919
steps:
2020
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}

.goreleaser.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ before:
1212
hooks:
1313
# you may remove this if you don't use vgo
1414
- go mod tidy
15+
- docker build -f Dockerfile.assets -t consoleassets .
16+
- docker create --name extract consoleassets
17+
- docker cp extract:/app/bindata_assetfs.go ./portal-ui/
18+
- docker rm extract
1519

1620
builds:
1721
-

Dockerfile

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
FROM golang:1.13
1+
FROM golang:1.15 as binlayer
2+
3+
RUN go get github.com/go-bindata/go-bindata/... && go get github.com/elazarl/go-bindata-assetfs/...
4+
5+
FROM node:10 as uilayer
6+
7+
WORKDIR /app
8+
9+
COPY --from=binlayer /go/bin/go-bindata-assetfs /bin/
10+
COPY --from=binlayer /go/bin/go-bindata /bin/
11+
12+
COPY ./portal-ui/package.json ./
13+
COPY ./portal-ui/yarn.lock ./
14+
RUN yarn install
15+
16+
COPY ./portal-ui .
17+
18+
RUN yarn install && make build-static
19+
20+
USER node
21+
22+
FROM golang:1.15 as golayer
223

324
RUN apt-get update -y && apt-get install -y ca-certificates
425

@@ -12,6 +33,8 @@ RUN go mod download
1233
ADD . /go/src/github.com/minio/console/
1334
WORKDIR /go/src/github.com/minio/console/
1435

36+
COPY --from=uilayer /app/bindata_assetfs.go /go/src/github.com/minio/console/portal-ui/
37+
1538
ENV CGO_ENABLED=0
1639

1740
RUN go build -ldflags "-w -s" -a -o console ./cmd/console
@@ -20,7 +43,7 @@ FROM scratch
2043
MAINTAINER MinIO Development "dev@min.io"
2144
EXPOSE 9090
2245

23-
COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
24-
COPY --from=0 /go/src/github.com/minio/console/console .
46+
COPY --from=golayer /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
47+
COPY --from=golayer /go/src/github.com/minio/console/console .
2548

2649
ENTRYPOINT ["/console"]

Dockerfile.assets

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM golang:1.15 as binlayer
2+
3+
RUN go get github.com/go-bindata/go-bindata/... && go get github.com/elazarl/go-bindata-assetfs/...
4+
5+
FROM node:10 as uilayer
6+
7+
WORKDIR /app
8+
9+
COPY --from=binlayer /go/bin/go-bindata-assetfs /bin/
10+
COPY --from=binlayer /go/bin/go-bindata /bin/
11+
12+
COPY ./portal-ui/package.json ./
13+
COPY ./portal-ui/yarn.lock ./
14+
RUN yarn install
15+
16+
COPY ./portal-ui .
17+
18+
RUN yarn install && make build-static
19+
20+
USER node

bindata_assetfs.go

Lines changed: 0 additions & 959 deletions
This file was deleted.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/minio/console
22

3-
go 1.13
3+
go 1.15
44

55
require (
66
github.com/coreos/go-oidc v2.2.1+incompatible

restapi/user_objects_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ func Test_shareObject(t *testing.T) {
755755
return "http://someurl", nil
756756
},
757757
},
758-
wantError: errors.New("time: invalid duration invalid"),
758+
wantError: errors.New("time: invalid duration \"invalid\""),
759759
},
760760
{
761761
test: "handle empty expire duration",
@@ -788,7 +788,7 @@ func Test_shareObject(t *testing.T) {
788788
url, err := getShareObjectURL(ctx, client, tt.args.versionID, tt.args.expires)
789789
if tt.wantError != nil {
790790
if !reflect.DeepEqual(err, tt.wantError) {
791-
t.Errorf("getShareObjectURL() error: %v, wantErr: %v", err, tt.wantError)
791+
t.Errorf("getShareObjectURL() error: `%s`, wantErr: `%s`", err, tt.wantError)
792792
return
793793
}
794794
} else {
@@ -988,7 +988,8 @@ func Test_putObjectRetention(t *testing.T) {
988988
miinoPutObjectRetentionMock = tt.args.retentionFunc
989989
err := setObjectRetention(ctx, client, tt.args.bucket, tt.args.prefix, tt.args.versionID, tt.args.opts)
990990
if tt.wantError != nil {
991-
assert.Equal(err.Error(), tt.wantError.Error(), fmt.Sprintf("setObjectRetention() error: %v, wantErr: %v", err, tt.wantError))
991+
fmt.Println(t.Name())
992+
assert.Equal(tt.wantError.Error(), err.Error(), fmt.Sprintf("setObjectRetention() error: `%s`, wantErr: `%s`", err, tt.wantError))
992993
} else {
993994
assert.Nil(err, fmt.Sprintf("setObjectRetention() error: %v, wantErr: %v", err, tt.wantError))
994995
}

0 commit comments

Comments
 (0)