Skip to content

Commit

Permalink
Merge pull request #352 from hngprojects/feature/update-env-action-usage
Browse files Browse the repository at this point in the history
chore: update env-action and trim Dockerfile
  • Loading branch information
vicradon authored Aug 11, 2024
2 parents 9490274 + 9826cb8 commit 5ef8046
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/staging-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
22 changes: 2 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5ef8046

Please sign in to comment.