简体   繁体   中英

Unable to deploy golang app to Azure app services container

I've tried a lot of Dockerfile samples to build my golang app, they're working fine running on local.

Here is the last one Dockerfile I tried

FROM golang:alpine
EXPOSE 80
RUN  mkdir -p /app
WORKDIR /app
COPY . .
RUN go mod download
RUN go build -o app
ENTRYPOINT ["./app"]

I push my image to my Azure Container registry and use it via App service(linux) Deployment Center.

errors I got:

在此处输入图像描述

You can try to solve your problem in the following two ways.

  1. According to your screenshot, you can add a startup command to the dockerfile.

    Reference link:

    1. How To Deploy a Go Web Application with Docker

    2. Changing RUN to CMD stops the container from working

  2. Make sure your files have been posted to the scm website. After under wwwroot, use the startup command to start your application.

     go run main.go

    Reference link:

    Step by step guide to deploy Golang Application on Azure Web App

I modified the port listening to 80 (App service default WEBSITE_PORT)

add ENV to Dockerfile

ENV GOOS=linux GOARCH=amd64

Change Entrypoint

ENTRYPOINT [/app/app]

finally works.

reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM