Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update env-action and trim Dockerfile #352

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading