Skip to content

Commit

Permalink
Merge pull request #78 from timescale/adn/update-docker
Browse files Browse the repository at this point in the history
Build and publish docker image
  • Loading branch information
alejandrodnm committed Apr 23, 2024
2 parents cb9383f + f408e30 commit c38500c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
30 changes: 28 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Go
name: Go CI, build and publish

on:
push:
branches: [master, main]
branches: [main]
pull_request:
branches: ["**"]

Expand Down Expand Up @@ -34,3 +34,29 @@ jobs:
- name: Test
run: go test -v ./...

build-and-push:
needs: build
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.ORG_DOCKER_HUB_USERNAME }}
password: ${{ secrets.ORG_DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: timescale/timescaledb-parallel-copy:latest
19 changes: 11 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
FROM golang:1.19-alpine3.15 AS build
FROM golang:1.22-alpine3.19 AS base

WORKDIR /stage
WORKDIR /github.com/timescale/csv-importer

COPY . .
COPY ./go.mod go.mod
COPY ./go.sum go.sum
RUN go mod download

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /stage/timescaledb-parallel-copy ./cmd/...
FROM base as builder
COPY ./cmd cmd
COPY ./internal internal

FROM scratch
RUN go build -o /bin/timescaledb-parallel-copy ./cmd/timescaledb-parallel-copy

WORKDIR /data
FROM alpine:3.19 as release

COPY --from=build /stage/timescaledb-parallel-copy /usr/bin/
COPY --from=builder /bin/timescaledb-parallel-copy /bin/timescaledb-parallel-copy

ENTRYPOINT [ "timescaledb-parallel-copy" ]

0 comments on commit c38500c

Please sign in to comment.