superfly / flyctl-actions

:octocat: GitHub Action that wraps the flyctl
Apache License 2.0
260 stars 33 forks source link

Can't find Dockerfile when deploy #34

Closed mingchau closed 1 year ago

mingchau commented 1 year ago

Files contents:

Dockerfile:

FROM python:3.10
RUN apt-get update && apt-get install -y \
    python3-pip \
    python3-venv \
    python3-dev \
    python3-setuptools \
    python3-wheel

COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "main.py"]

fly.toml

# fly.toml file generated for white-morning-129 on 2023-01-11T20:36:32+08:00

app = "some-appname-129"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

.github\workflows\fly.yml

name: Fly Deploy
on:
  push:
    branches:
      - main
env:
  FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
jobs:
  deploy:
      name: Deploy app
      runs-on: ubuntu-latest
      steps:
        - name: Checkout Code
          uses: actions/checkout@v3

        - name: Setup Flyctl
          uses: superfly/flyctl-actions/setup-flyctl@master

        - name: List Files in Current Dir
          run: ls

        - name: Deploy App
          run: flyctl deploy

GitHub Repo file structure: image

GitHub Actions Log: image image

eliasj commented 1 year ago

Hi! I tried your fly.yml and it worked for me.

One difference I could find in your fly.toml was that I got this line

[build]
  dockerfile = "Dockerfile"

Maybe that will help

Also, my Dockerfile also looks different, but I'm running a Django app.

ARG PYTHON_VERSION=3.10-slim-buster
FROM python:${PYTHON_VERSION}
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN mkdir -p /code
WORKDIR /code
COPY requirements.txt /tmp/requirements.txt
RUN set -ex && \
    pip install --upgrade pip && \
    pip install -r /tmp/requirements.txt && \
    rm -rf /root/.cache/
COPY . /code/
RUN python ./manage.py collectstatic
EXPOSE 8000
CMD ["gunicorn", "--bind", ":8000", "--workers", "2", "mysite.wsgi"]

Can you deploy it from your own computer?

eliasj commented 1 year ago

Ohh, I missed one thing. I added --remote-only on the last line in fly.yml, so it looks like this: flyctl deploy --remote-only. All the docs got it.

mingchau commented 1 year ago

Hi @eliasj , thank you for the reply. Yes, I could deploy it with my own Windows 10 PC and flyctl deploy --local-only command, but flyctl deploy --remote-only command on my PC always stuck on

Waiting for remote builder

That's why I want to try to deploy it with GitHub Actions.

After adding

[build]
  dockerfile = "Dockerfile"

and --remote-only in the specified files, it still fails with the similar error message. image

Can you please share more about your fly.yml file?

mingchau commented 1 year ago

Finally, I found the problem was caused by the .dockerignore file, which was auto-generated, so I've assumed it's ok.😅

There is error log which I ignored says:

time="**" level=error msg="Error matching .dockerignore: syntax error in pattern"

Replacing the \ with / in the .dockerignore file, everything goes good!

eliasj commented 1 year ago

Are you running on a Windows machine? Just for reference, if someone gets this error in the future.

mingchau commented 1 year ago

Are you running on a Windows machine? Just for reference, if someone gets this error in the future.

Sorry, I made a typo in the previous reply, it should be the .dockerignore file, not the .gitignore file. I have edited it. Yes, I am using a Windows PC. The file was generated by flyctl.