Skip to content

Commit

Permalink
Pref: update a better docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleChair committed Jul 9, 2024
1 parent fe7d40f commit 31949d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
16 changes: 8 additions & 8 deletions content/web-server/additional/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ atlas migrate apply --env local

To make it more convenient, we could modify our dockerfile:
```dockerfile {filename="Dockerfile"}
FROM golang:1.22-alpine as base

FROM base as dev
FROM golang:1.22-alpine as builder
WORKDIR /tmp
RUN wget -O gf "https://github.com/gogf/gf/releases/latest/download/gf_$(go env GOOS)_$(go env GOARCH)" && \
chmod +x gf && \
./gf install -y && \
rm ./gf

FROM golang:1.22-alpine as dev
WORKDIR /var/www

COPY --from=builder /go/bin/gf /go/bin/gf
COPY --from=arigaio/atlas:latest-alpine /atlas /usr/local/bin/atlas
COPY manifest/database/migrations /migrations
CMD atlas migrate apply --env docker && \
wget -O gf "https://github.com/gogf/gf/releases/latest/download/gf_$(go env GOOS)_$(go env GOARCH)" && \
chmod +x gf && \
./gf install -y && \
rm ./gf && \
gf run main.go

ENV DEBIAN_FRONTEND noninteractive
Expand Down
15 changes: 8 additions & 7 deletions content/web-server/initial/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,16 +265,17 @@ After finishing all the configurations, finally we could start setting the conta

Create a `Dockerfile` in your project folder:
```dockerfile {filename="Dockerfile"}
FROM golang:1.22-alpine as base
FROM base as dev
WORKDIR /var/www
CMD wget -O gf "https://github.com/gogf/gf/releases/latest/download/gf_$(go env GOOS)_$(go env GOARCH)" && \
FROM golang:1.22-alpine as builder
WORKDIR /tmp
RUN wget -O gf "https://github.com/gogf/gf/releases/latest/download/gf_$(go env GOOS)_$(go env GOARCH)" && \
chmod +x gf && \
./gf install -y && \
rm ./gf && \
gf run main.go
rm ./gf
FROM golang:1.22-alpine as dev
WORKDIR /var/www
COPY --from=builder /go/bin/gf /go/bin/gf
CMD gf run main.go
ENV DEBIAN_FRONTEND noninteractive
RUN apk add --no-cache tzdata
ENV TZ=Asia/Shanghai
Expand Down

0 comments on commit 31949d9

Please sign in to comment.