thomaspeugeot / gongtenk

0 stars 0 forks source link

create a docker image for deployment #3

Closed thomaspeugeot closed 2 years ago

thomaspeugeot commented 2 years ago

Steps :

FROM golang:1.16-alpine

# Set destination for COPY
WORKDIR /

# Download Go modules
COPY go.mod .
COPY go.sum .
RUN go mod download

# Copy the source code. Note the slash at the end, as explained in
# https://docs.docker.com/engine/reference/builder/#copy
COPY go ./
COPY ng/dist/ng ./ng/dist/ng
COPY embed.go ./

# Build
RUN go build go/cmd/gongtenk -o ./go/cmd/gongtenk

# This is for documentation purposes only.
# To actually open the port, runtime parameters
# must be supplied to the docker command.
EXPOSE 8080

# Run
CMD [ "/docker-gongtenk" ]
thomaspeugeot commented 2 years ago

Problem:

thomaspeugeot@MacBook-Pro-de-Thomas gongtenk % docker build --tag docker-gongtenk .
[+] Building 6.1s (9/13)                                                                                             
 => [internal] load build definition from Dockerfile                                                            0.0s
 => => transferring dockerfile: 826B                                                                            0.0s
 => [internal] load .dockerignore                                                                               0.0s
 => => transferring context: 2B                                                                                 0.0s
 => [internal] load metadata for docker.io/library/golang:1.16-alpine                                           1.6s
 => [auth] library/golang:pull token for registry-1.docker.io                                                   0.0s
 => CACHED [1/9] FROM docker.io/library/golang:1.16-alpine@sha256:423de38f9cb9227dd0c89bc54896369333e13c38ceb1  0.0s
 => [internal] load build context                                                                               1.9s
 => => transferring context: 109.61MB                                                                           1.8s
 => [2/9] COPY go.mod .                                                                                         0.2s
 => [3/9] COPY go.sum .                                                                                         0.0s
 => ERROR [4/9] RUN go mod download                                                                             2.4s
------                                                                                                               
 > [4/9] RUN go mod download:                                                                                        
#9 2.375 go: github.com/fullstack-lang/gongxlsx@v0.0.0-20211110082428-9aa1df985333: git init --bare in /go/pkg/mod/cache/vcs/189666a4593c9af12f434b618e8821fb2ca26ce295b16f8d29cb34c5d667e555: exec: "git": executable file not found in $PATH
------
executor failed running [/bin/sh -c go mod download]: exit code: 1

This is because the go:1.16-alpline is very slim. Let's go

thomaspeugeot commented 2 years ago

fatal: could not read Username for 'https://github.com': terminal prompts disabled

gongxlsx was private !

thomaspeugeot commented 2 years ago

=> [ 5/10] RUN go mod download 685.0s

thomaspeugeot commented 2 years ago

14 1.179 # gongtenk

14 1.179 /embed.go:8:5: embed g/dist/ng/3rdpartylicenses.txt: open /g/dist/ng/3rdpartylicenses.txt: no such file or directory

Apparently, go in docker mangles he path. Let's go back to the tutorial exemple and see if it is the same issue.