From 9826cb80417ea354ad5d5c79e449fc6310a48b31 Mon Sep 17 00:00:00 2001 From: Osinachi Chukwujama Date: Sun, 11 Aug 2024 11:12:12 +0100 Subject: [PATCH] chore: update env-action and trim Dockerfile --- .github/workflows/dev-deploy.yml | 3 ++- .github/workflows/staging-deploy.yml | 3 ++- Dockerfile | 22 ++-------------------- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/.github/workflows/dev-deploy.yml b/.github/workflows/dev-deploy.yml index ad45c48..04cc92a 100644 --- a/.github/workflows/dev-deploy.yml +++ b/.github/workflows/dev-deploy.yml @@ -44,9 +44,10 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Create app.env file - uses: vicradon/create-env-action@v0.0.8 + uses: vicradon/create-env-action@v1.0.0 with: action_input_file: "app-sample.env" + action_output_file: "app.env" APP_NAME: "development" APP_URL: "https://deployment.api-golang.boilerplate.hng.tech" SERVER_PORT: ${{ secrets.SERVER_PORT }} diff --git a/.github/workflows/staging-deploy.yml b/.github/workflows/staging-deploy.yml index f00612c..d4105f9 100644 --- a/.github/workflows/staging-deploy.yml +++ b/.github/workflows/staging-deploy.yml @@ -44,9 +44,10 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Create app.env file - uses: vicradon/create-env-action@v0.0.8 + uses: vicradon/create-env-action@v1.0.0 with: action_input_file: "app-sample.env" + action_output_file: "app.env" APP_NAME: "staging" APP_URL: "https://staging.api-golang.boilerplate.hng.tech" SERVER_PORT: ${{ secrets.SERVER_PORT }} diff --git a/Dockerfile b/Dockerfile index 7bbf13b..12e8e9f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,37 +1,19 @@ -# Build stage FROM golang:1.20.1-alpine3.17 as build -# Set the Current Working Directory inside the container WORKDIR /usr/src/app -# Copy go.mod and go.sum files COPY go.mod go.sum ./ - -# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed RUN go mod download && go mod verify -# Copy the source code into the container +# Copy the source code into the container and build the app COPY . . - -# Build the Go app RUN go build -v -o /dist/golang_app -# Wait-for-it stage -FROM alpine:3.17 as wait -RUN apk add --no-cache bash -ADD https://github.com/vishnubob/wait-for-it/raw/master/wait-for-it.sh /wait-for-it.sh -RUN chmod +x /wait-for-it.sh - # Deployment stage FROM alpine:3.17 WORKDIR /usr/src/app COPY --from=build /usr/src/app ./ COPY --from=build /dist/golang_app /usr/local/bin/golang_app -COPY --from=wait /wait-for-it.sh /wait-for-it.sh - -# Install bash (required for wait-for-it script) -RUN apk add --no-cache bash -# Wait for DB and Redis, then start the application -# CMD /wait-for-it.sh $DB_HOST:$DB_PORT -t 10 -- /wait-for-it.sh $REDIS_HOST:$REDIS_PORT -t 10 -- golang_app +# Start the application CMD golang_app