Skip to content

Commit

Permalink
chore: update dockerfile (#1188)
Browse files Browse the repository at this point in the history
* chore: update dockerfile

* chore: update CI
  • Loading branch information
lmquang authored Sep 15, 2023
1 parent 1c7c7c4 commit 3e2b408
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:

# Service containers to run with `container-job`
services:
# Label used to access the service container
# pg test
postgres:
# Docker Hub image
image: postgres:15
Expand All @@ -22,7 +22,29 @@ jobs:
--health-retries 5
ports:
- 25433:5432

# pg local
postgres_local:
# Docker Hub image
image: postgres:15
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: mochi_local
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5434:5432
# chrome
chrome:
# Docker Hub image
image: browserless/chrome
ports:
- 3000:3000
# redis
redis:
image: redis:6
ports:
Expand All @@ -37,5 +59,7 @@ jobs:
go-version-file: go.mod
- name: Install
run: go install github.com/rubenv/sql-migrate/sql-migrate@latest
- name: Migrate pg local
run: make migrate-up
- name: Run Test cases
run: make test
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM golang:1.20-alpine
FROM dwarvesf/sql-migrate as sql-migrate

FROM golang:1.20-alpine as builder
RUN mkdir /build
WORKDIR /build
COPY . .
Expand All @@ -9,15 +11,15 @@ RUN set -ex && \
apk add --no-progress --no-cache \
gcc \
musl-dev
RUN go install --tags musl -v ./...
RUN go install -v github.com/rubenv/sql-migrate/sql-migrate@latest
RUN go install --tags musl ./...

FROM alpine:3.15.0
RUN apk --no-cache add ca-certificates
RUN ln -fs /usr/share/zoneinfo/Asia/Ho_Chi_Minh /etc/localtime
WORKDIR /

COPY --from=0 /go/bin/* /usr/bin/
COPY --from=sql-migrate /usr/local/bin/sql-migrate /usr/bin/
COPY --from=builder /go/bin/* /usr/bin/
COPY migrations /migrations
COPY images /images
COPY dbconfig.yml /
Expand Down

0 comments on commit 3e2b408

Please sign in to comment.