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 dockerfile #1188

Merged
merged 7 commits into from
Sep 15, 2023
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
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