Skip to content

Commit

Permalink
Add GHA to generate docker image for dsrelay
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier-romero committed Dec 22, 2023
1 parent ac1abe7 commit 29c6731
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 11 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/push-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
push:
branches:
- main
- feature/dockerfile
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
push: true
tags: |
hermeznetwork/zkevm-dsrelay:latest
30 changes: 19 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
# CONTAINER FOR BUILDING BINARY
# FROM golang:1.21 AS build
FROM golang:1.21 AS build

# INSTALL DEPENDENCIES
# RUN go install github.com/gobuffalo/packr/v2/packr2@v2.8.3
# COPY go.mod go.sum /src/
# RUN cd /src && go mod download
RUN go install github.com/gobuffalo/packr/v2/packr2@v2.8.3
COPY go.mod go.sum /src/
RUN cd /src && go mod download

# BUILD BINARY
# COPY . /src
# RUN cd /src && make build-dsrelay
COPY . /src
RUN cd /src && make build-dsrelay

# CONTAINER FOR RUNNING BINARY
# FROM alpine:3.18.4
# COPY --from=build /src/dist/dsrelay /app/dsrelay
# COPY --from=build /src/config/environments/testnet/config.toml /app/sample.config.toml
# EXPOSE 7900
# CMD ["/bin/sh", "-c", "/app/dsrelay"]
FROM alpine:3.19.0

COPY --from=build /src/dist/dsrelay /app/dsrelay
COPY --from=build /src/config/environments/testnet/config.toml /app/sample.config.toml

ARG USER=dsrelay
ENV HOME /home/$USER
RUN adduser -D $USER
USER $USER
WORKDIR $HOME

EXPOSE 7900
CMD ["/bin/sh", "-c", "/app/dsrelay"]

0 comments on commit 29c6731

Please sign in to comment.