From 5347de1f18321c1f053b390016571796094d7491 Mon Sep 17 00:00:00 2001 From: Kyle Jackson Date: Mon, 26 Aug 2024 20:56:06 +1000 Subject: [PATCH] added api build --- .github/workflows/build-images.yml | 70 +++++++++++++++++++++++++++++- .gitignore | 2 + build/api/Dockerfile | 14 ++++++ 3 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 build/api/Dockerfile diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index b428497..2d53dfa 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -106,7 +106,7 @@ jobs: ghcr.io/wizedkyle/artifactsmmo/woodcutting:1.0.${{ github.run_id }} build-fishing-image: - name: Build Woodcutting Image + name: Build Fishing Image runs-on: ubuntu-latest permissions: packages: write @@ -136,4 +136,70 @@ jobs: platforms: linux/amd64 tags: | ghcr.io/wizedkyle/artifactsmmo/fishing:latest - ghcr.io/wizedkyle/artifactsmmo/fishing:1.0.${{ github.run_id }} \ No newline at end of file + ghcr.io/wizedkyle/artifactsmmo/fishing:1.0.${{ github.run_id }} + + build-worker-image: + name: Build Worker Image + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Setup QEMU + uses: docker/setup-qemu-action@v3 + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Azure Container Registry + uses: docker/login-action@v3 + with: + registry: "ghcr.io" + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push image + uses: docker/build-push-action@v5 + with: + context: . + push: true + file: build/worker/Dockerfile + platforms: linux/amd64 + tags: | + ghcr.io/wizedkyle/artifactsmmo/worker:latest + ghcr.io/wizedkyle/artifactsmmo/worker:1.0.${{ github.run_id }} + + build-api-image: + name: Build API Image + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Setup QEMU + uses: docker/setup-qemu-action@v3 + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Azure Container Registry + uses: docker/login-action@v3 + with: + registry: "ghcr.io" + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push image + uses: docker/build-push-action@v5 + with: + context: . + push: true + file: build/api/Dockerfile + platforms: linux/amd64 + tags: | + ghcr.io/wizedkyle/artifactsmmo/api:latest + ghcr.io/wizedkyle/artifactsmmo/api:1.0.${{ github.run_id }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6f72f89..83c3beb 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ go.work.sum # env file .env + +tmp/* \ No newline at end of file diff --git a/build/api/Dockerfile b/build/api/Dockerfile new file mode 100644 index 0000000..572083e --- /dev/null +++ b/build/api/Dockerfile @@ -0,0 +1,14 @@ +FROM golang:1.22.5-alpine3.20 + +ENV PORT=9000 + +WORKDIR /go/src/api + +COPY . /go/src/api + +RUN go get ./... +RUN go build ./cmd/api + +EXPOSE $PORT + +ENTRYPOINT ["./api"] \ No newline at end of file