-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from nikhilnarayanan623/fix/docker
docker file and compse file updated
- Loading branch information
Showing
3 changed files
with
39 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
FROM golang:1.20.4-alpine3.18 AS build-stage | ||
WORKDIR /home/app | ||
COPY ./ /home/app | ||
RUN mkdir -p /home/build | ||
RUN go mod download | ||
RUN go build -v -o /home/build/api ./cmd/api | ||
# build stage | ||
FROM golang:1.20.6-alpine3.18 AS build-stage | ||
|
||
WORKDIR /app | ||
# download the dependancy | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
# copy the source code and html files | ||
COPY cmd cmd/ | ||
COPY pkg pkg/ | ||
COPY views views/ | ||
# build the executable file | ||
RUN go build -v -o ./build/api ./cmd/api | ||
|
||
# final stage | ||
FROM gcr.io/distroless/static-debian11 | ||
COPY --from=build-stage /home/build/api /api | ||
COPY --from=build-stage /home/app/views /views | ||
CMD ["/api"] | ||
|
||
WORKDIR /app | ||
# copy the binay file and html files | ||
COPY --from=build-stage /app/build/api api | ||
COPY --from=build-stage /app/views views/ | ||
|
||
CMD ["/app/api"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,36 @@ | ||
version: '3' | ||
services: | ||
#database container | ||
# database container | ||
postgresdb: | ||
image: postgres | ||
# ports: | ||
# - 5454:5432 | ||
environment: | ||
- POSTGRES_USER=${DB_USER} | ||
- POSTGRES_PASSWORD=password | ||
- POSTGRES_DB=${DB_NAME} | ||
env_file: | ||
- .env | ||
volumes: | ||
- database:/var/lib/postgresql/data | ||
networks: | ||
- ecommerce-network | ||
# webapp container | ||
app: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
image: nikhil382/ecommerce-gin-clean-arch | ||
ports: | ||
- 8000:8000 | ||
env_file: | ||
- .env | ||
environment: | ||
- ADMIN_EMAIL=${ADMIN_EMAIL} | ||
- ADMIN_USER_NAME=${ADMIN_USER_NAME} | ||
- ADMIN_PASSWORD=${ADMIN_PASSWORD} | ||
- DB_HOST=postgresdb | ||
- DB_USER=${DB_USER} | ||
- DB_PASSWORD=password | ||
- DB_NAME=${DB_NAME} | ||
- DB_PORT=5432 | ||
- ADMIN_AUTH_KEY=${ADMIN_AUTH_KEY} | ||
- USER_AUTH_KEY=${USER_AUTH_KEY} | ||
- AUTH_TOKEN=${AUTH_TOKEN} | ||
- ACCOUNT_SID=${ACCOUNT_SID} | ||
- SERVICE_SID=${SERVICE_SID} | ||
- RAZOR_PAY_KEY=${RAZOR_PAY_KEY} | ||
- RAZOR_PAY_SECRET=${RAZOR_PAY_SECRET} | ||
- STRIPE_SECRET=${STRIPE_SECRET} | ||
- STRIPE_PUBLISH_KEY=${STRIPE_PUBLISH_KEY} | ||
- STRIPE_WEBHOOK=${STRIPE_WEBHOOK} | ||
- GOAUTH_CLIENT_ID=${GOAUTH_CLIENT_ID} | ||
- GOAUTH_CLIENT_SECRET=${GOAUTH_CLIENT_SECRET} | ||
- GOAUTH_CALL_BACK_URL=${GOAUTH_CALL_BACK_URL} | ||
depends_on: | ||
- postgresdb | ||
restart: always | ||
networks: | ||
- ecommerce-network | ||
|
||
# # pg admin for showing the database on GUI | ||
# pg-admin: | ||
# image: dpage/pgadmin4 | ||
# ports: | ||
# - 8080:80 | ||
# environment: | ||
# - PGADMIN_DEFAULT_EMAIL=nikhil@gmail.com | ||
# - PGADMIN_DEFAULT_PASSWORD=password | ||
|
||
# storing datas on docker side | ||
# for persistent data storage | ||
volumes: | ||
database: | ||
driver: local | ||
|
||
networks: | ||
ecommerce-network: | ||
driver: bridge |