Skip to content

Commit

Permalink
fix: update dockerfile path
Browse files Browse the repository at this point in the history
  • Loading branch information
iamjooon2 committed Sep 13, 2024
1 parent 28dab48 commit 6b8379c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 30 deletions.
21 changes: 5 additions & 16 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.22.5

- name: Create .env file from secret
run: echo "${{ secrets.ENV }}" > .env

- name: Build
- name: Build Docker image
run: |
mkdir -p ./bin
go build -v -o ./bin/techbloghub ./...
docker build -t techbloghub .
- name: Login to DockerHub
uses: docker/login-action@v1
Expand All @@ -38,13 +36,4 @@ jobs:
docker build . -t techbloghub
docker run -p 3000:3000 techbloghub
deploy:
runs-on: self-hosted
steps:
- name: change permission
run: |
sudo chown -R ubuntu:ubuntu /home/ubuntu/actions-runner/_work/server
- uses: actions/checkout@v3
- name: deploy
run: sudo cd /home/ubuntu && sudo ./deploy.sh
23 changes: 9 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
FROM golang:alpine AS builder
FROM golang:1.22.5 AS builder

ENV GO125MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64
WORKDIR /app

WORKDIR /build

COPY go.mod go.sum main.go ./
COPY go.mod go.sum ./

RUN go mod download

RUN go build -o main .
COPY . .

WORKDIR /dist
RUN CGO_ENABLED=0 GOOS=linux go build -o myapp .

RUN cp /build/main .
FROM alpine:latest

FROM scratch
WORKDIR /root/

COPY --from=builder /dist/main .
COPY --from=builder /app/myapp .

ENTRYPOINT ["/main"]
CMD ["./myapp"]

0 comments on commit 6b8379c

Please sign in to comment.