Skip to content

Commit

Permalink
Feat/build container (#387)
Browse files Browse the repository at this point in the history
* - action pour build et push le conteneur

* - local_data

* Changes by raphaelsquelbut

* fix workflow

* fix workflow / go build

* try broken binary name (test)

* fix broken binary name (test)

* newer method to set chmod sfdata

* full path for binary in Dockerfile

* add go generate to container build

* npm install before go generate

Co-authored-by: Christophe Ninucci <[email protected]>
  • Loading branch information
chrnin and Christophe Ninucci authored Jan 23, 2023
1 parent 3d75d6e commit e531b0d
Show file tree
Hide file tree
Showing 10 changed files with 4,654 additions and 3 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build & Push Container vers ghcr.io

on:
push:
branches:
release:
types: [published, edited]
pull_request:
branches:
- 'master'

jobs:
container_datapi:
name: Push OpenSignauxFaibles container
runs-on: ubuntu-latest
steps:

- name: Check out code
uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 12

- name: Set up Go 1.14
uses: actions/setup-go@v3
with:
go-version: 1.14
id: go

- name: Prepare js sources
run: npm install --prefer-offline --no-audit
working-directory: js

- name: Prepare container sources & resources
shell: bash
run: |
go generate -x ./...
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o sfdata
cp ./sfdata ./build-container
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
flavor: |
latest=true
- name: Login to GitHub Container Registry
id: login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: ./build-container
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
3 changes: 1 addition & 2 deletions build-container/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM alpine:3.12
COPY ./$path/sfdata /app
RUN chmod 555 /app/sfdata
COPY --chmod=555 sfdata /app/sfdata
WORKDIR /app
EXPOSE 3000
CMD ["/app/sfdata"]
2 changes: 1 addition & 1 deletion build-container/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fi
unzip "$1.zip"
cd "opensignauxfaibles-$1/"

CGO_ENABLED=0 GOARCH=amd64 go build -o "sfdata"
make build-prod

# Build docker
cd ../../..
Expand Down
Loading

0 comments on commit e531b0d

Please sign in to comment.