Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,9 @@ server {
rewrite ^/api/v2-old(.*)$ /api/v2$1 permanent;
rewrite ^/api/v2-redoc(.*)$ /api/v2$1 permanent;

# Actor marketing playbook addition
rewrite ^/academy/get-most-of-actors$ /academy/actor-marketing-playbook permanent;
# Actor marketing playbook redirects (index page removed)
rewrite ^/academy/get-most-of-actors$ /academy/actor-marketing-playbook/promote-your-actor/checklist permanent;
rewrite ^/academy/actor-marketing-playbook$ /academy/actor-marketing-playbook/promote-your-actor/checklist permanent;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Direct Redirect Chain Causes SEO Overhead

Redirect chain detected: /academy/get-most-of-actors redirects to /academy/actor-marketing-playbook (line 647), which then immediately redirects to /academy/actor-marketing-playbook/promote-your-actor/checklist (line 650). This creates an unnecessary intermediate redirect. For better performance and SEO, line 647 should redirect directly to /academy/actor-marketing-playbook/promote-your-actor/checklist instead of creating a chain.

Fix in Cursor Fix in Web


# Misc
rewrite ^/platform/integrations/llama$ /platform/integrations/llama-index permanent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@ Deployment to Apify platform can be done easily via `apify push` command of [Api

### 6. Publish and monetize

For details on publishing the Actor in [Apify Store](https://apify.com/store) see the [Publishing and monetization](/platform/actors/publishing). You can also follow our guide on [How to create an Actor README](/academy/actor-marketing-playbook/actor-basics/how-to-create-an-actor-readme) and [Actor marketing playbook](/academy/actor-marketing-playbook).
For details on publishing the Actor in [Apify Store](https://apify.com/store) see the [Publishing and monetization](/platform/actors/publishing). You can also follow our guide on [How to create an Actor README](/academy/actor-marketing-playbook/actor-basics/how-to-create-an-actor-readme) and [Marketing checklist](/academy/actor-marketing-playbook/promote-your-actor/checklist).
2 changes: 0 additions & 2 deletions sources/academy/platform/apify_platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ category: apify platform
slug: /apify-platform
---

# Introduction to the Apify platform {#about-the-platform}

**Learn all about the Apify platform, all of the tools it offers, and how it can improve your overall development experience.**

---
Expand Down
24 changes: 18 additions & 6 deletions sources/academy/platform/deploying_your_code/deploying.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: Publishing your Actor
description: Push local code to the platform, or create a new Actor on the console and integrate it with a Git repository to optionally automatically rebuild any new changes.
description: Push local code to the platform, or create an Actor and integrate it with a Git repository for automatic rebuilds.
sidebar_position: 5
slug: /deploying-your-code/deploying
---

**Push local code to the platform, or create a new Actor on the console and integrate it with a Git repository to optionally automatically rebuild any new changes.**
**Push local code to the platform, or create an Actor and integrate it with a Git repository for automatic rebuilds.**

---

Expand All @@ -15,7 +15,11 @@ Once you've **actorified** your code, there are two ways to deploy it to the Api

Before we deploy our project onto the Apify platform, let's ensure that we've pushed the changes we made in the last 3 lessons into our remote GitHub repository.

> The benefit of using this method is that any time you push to the Git repository, the code on the platform is also updated and the Actor is automatically rebuilt. Also, you don't have to use a GitHub repository - you can use GitLab or any other service you'd like.
:::tip Git integration

The benefit of using this method is that any time you push to the Git repository, the code on the platform is also updated and the Actor is automatically rebuilt. Also, you don't have to use a GitHub repository - you can use GitLab or any other service you'd like.

:::

### Creating the Actor

Expand Down Expand Up @@ -45,13 +49,21 @@ That's it! The Actor should now pull its source code from the repository and aut

## Without a GitHub repository (using the Apify CLI) {#with-apify-cli}

> If you don't yet have the Apify CLI, learn how to install it and log in by following along with [this brief lesson](../../glossary/tools/apify_cli.md) about it.
:::info CLI prerequisite

If you don't yet have the Apify CLI, learn how to install it and log in by following along with [this brief lesson](../../glossary/tools/apify_cli.md) about it.

:::

If you're logged in to the Apify CLI, the `apify push` command can be used to push the code straight onto the Apify platform from your local machine (no GitHub repository required), where it will automatically be built for you. Prior to running this command, make sure that you have an **.actor/actor.json** file at the root of the project. If you don't already have one, you can use `apify init .` to automatically generate one for you.

One important thing to note is that you can use a `.gitignore` file to exclude files from being pushed. When you use `apify push` without a `.gitignore`, the full folder contents will be pushed, meaning that even the **storage** and **node_modules** will be pushed. These files are unnecessary to push, as they are both generated on the platform.
One important thing to note is that you can use a `.gitignore` file to exclude files from being pushed. When you use `apify push` without a `.gitignore`, the full folder contents will be pushed, meaning that even the `storage` and `node_modules` will be pushed. These files are unnecessary to push, as they are both generated on the platform.

:::caution Development only

The `apify push` command should only really be used for quickly pushing and testing Actors on the platform during development. If you are ready to make your Actor public, use a Git repository instead, as you will reap the benefits of using Git and others will be able to contribute to the project.

> The `apify push` command should only really be used for quickly pushing and testing Actors on the platform during development. If you are ready to make your Actor public, use a Git repository instead, as you will reap the benefits of using Git and others will be able to contribute to the project.
:::

## Deployed! {#deployed}

Expand Down
30 changes: 23 additions & 7 deletions sources/academy/platform/deploying_your_code/docker_file.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
---
title: Creating Actor Dockerfile
description: Understand how to write a Dockerfile (Docker image blueprint) for your project so that it can be run within a Docker container on the Apify platform.
description: Learn to write a Dockerfile for your project so it can run in a Docker container on the Apify platform.
sidebar_position: 4
slug: /deploying-your-code/docker-file
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

**Understand how to write a Dockerfile (Docker image blueprint) for your project so that it can be run within a Docker container on the Apify platform.**
**Learn to write a Dockerfile for your project so it can run in a Docker container on the Apify platform.**

---

The **Dockerfile** is a file which gives the Apify platform (or Docker, more specifically) instructions on how to create an environment for your code to run in. Every Actor must have a Dockerfile, as Actors run in Docker containers.

> Actors on the platform are always run in Docker containers; however, they can also be run in local Docker containers. This is not common practice though, as it requires more setup and a deeper understanding of Docker. For testing, it's best to run the Actor on the local OS (this requires you to have the underlying runtime installed, such as Node.js, Python, Rust, GO, etc).
:::note Local testing

Actors on the platform are always run in Docker containers, however, they can also be run in local Docker containers. This is not common practice though, as it requires more setup and a deeper understanding of Docker. For testing, it's best to run the Actor on the local OS (this requires you to have the underlying runtime installed, such as Node.js, Python, Rust, GO, etc).

:::

## Base images {#base-images}

If your project doesn’t already contain a Dockerfile, don’t worry! Apify offers [many base images](/sdk/js/docs/guides/docker-images) that are optimized for building and running Actors on the platform, which can be found on [Docker Hub](https://hub.docker.com/u/apify). When using a language for which Apify doesn't provide a base image, [Docker Hub](https://hub.docker.com/) provides a ton of free Docker images for most use-cases, upon which you can create your own images.
If your project doesn't already contain a Dockerfile, don't worry! Apify offers [many base images](/sdk/js/docs/guides/docker-images) that are optimized for building and running Actors on the platform, which can be found on [Docker Hub](https://hub.docker.com/u/apify). When using a language for which Apify doesn't provide a base image, [Docker Hub](https://hub.docker.com/) provides a ton of free Docker images for most use-cases, upon which you can create your own images.

:::tip DockerHub images

You can see all of Apify's Docker images [on DockerHub](https://hub.docker.com/u/apify).

> Tip: You can see all of Apify's Docker images [on DockerHub](https://hub.docker.com/u/apify).
:::

At the base level, each Docker image contains a base operating system and usually also a programming language runtime (such as Node.js or Python). You can also find images with preinstalled libraries or install them yourself during the build step.

Expand All @@ -30,13 +38,21 @@ Once you find the base image you need, you can add it as the initial `FROM` stat
FROM apify/actor-node:16
```

> For syntax highlighting in your Dockerfiles, download the [**Docker** VSCode extension](https://code.visualstudio.com/docs/containers/overview#_installation).
:::tip VSCode extension

For syntax highlighting in your Dockerfiles, download the [Docker VSCode extension](https://code.visualstudio.com/docs/containers/overview#_installation).

:::

## Writing the file {#writing-the-file}

The rest of the Dockerfile is about copying the source code from the local filesystem into the container's filesystem, installing libraries, and setting the `RUN` command (which falls back to the parent image).

> If you are not using a base image from Apify, then you should specify how to launch the source code of your Actor with the `CMD` instruction.
:::info Custom images

If you are not using a base image from Apify, then you should specify how to launch the source code of your Actor with the `CMD` instruction.

:::

Here's the Dockerfile for our Node.js example project's Actor:

Expand Down
18 changes: 9 additions & 9 deletions sources/academy/platform/deploying_your_code/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@ slug: /deploying-your-code
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Deploying your code to Apify {#deploying}

**In this course learn how to take an existing project of yours and deploy it to the Apify platform as an Actor.**

---

This section will discuss how to use your newfound knowledge of the Apify platform and Actors from the [**Getting started**](../getting_started/index.md) section to deploy your existing project's code to the Apify platform as an Actor.
This section discusses how to use your newfound knowledge of the Apify platform and Actors from the [**Getting started**](../getting_started/index.md) section to deploy your existing project's code to the Apify platform as an Actor.
Any program running in a Docker container can become an Apify Actor.

![The deployment workflow](../../images/deployment-workflow.png)

Apify provides detailed guidance on how to deploy Node.js and Python programs as Actors, but apart from that you're not limited in what programming language you choose for your scraper.

![Supported languages](../../images/supported-languages.jpg)
Expand All @@ -30,12 +26,12 @@ Here are a few examples of Actors in other languages:
- [Go Actor](https://apify.com/jirimoravcik/go-actor-example)
- [Julia Actor](https://apify.com/jirimoravcik/julia-actor-example)

## The "actorification" workflow {#workflow}
## The "Actorization" workflow {#workflow}

Follow these four main steps to turn a piece of code into an Actor:

1. Handle [accepting inputs and writing outputs](./inputs_outputs.md).
2. Create an [input schema](./input_schema.md) **(optional)**.
2. Create an [input schema](./input_schema.md) _(optional)_.
3. Add a [Dockerfile](./docker_file.md).
4. [Deploy](./deploying.md) to the Apify platform!

Expand Down Expand Up @@ -73,10 +69,14 @@ print(add_all_numbers([1, 2, 3, 4])) # -> 10
</TabItem>
</Tabs>

> For all lessons in this section, we'll have examples for both Node.js and Python so that you can follow along in either language.
:::note Language examples

For all lessons in this section, we'll have examples for both Node.js and Python so that you can follow along in either language.

:::

<!-- We've pushed this code to GitHub and are ready to turn it into an Actor that takes any number of integers as input, adds them all up, then stores the solution as its output. -->

## Next up {#next}
## Next up

[Next lesson](./inputs_outputs.md), we'll be learning how to accept input into our Actor as well as deliver output.
10 changes: 7 additions & 3 deletions sources/academy/platform/deploying_your_code/input_schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ slug: /deploying-your-code/input-schema

---

Though writing an [input schema](/platform/actors/development/actor-definition/input-schema) for an Actor is not a required step, it is most definitely an ideal one. The Apify platform will read the **INPUT_SCHEMA.json** file within the root of your project and generate a user interface for entering input into your Actor, which makes it significantly easier for non-developers (and even developers) to configure and understand the inputs your Actor can receive. Because of this, we'll be writing an input schema for our example Actor.
Though writing an [input schema](/platform/actors/development/actor-definition/input-schema) for an Actor is not a required step, it's definitely an ideal one. The Apify platform will read the `INPUT_SCHEMA.json` file within the root of your project and generate a user interface for entering input into your Actor, which makes it significantly easier for non-developers (and even developers) to configure and understand the inputs your Actor can receive. Because of this, we'll be writing an input schema for our example Actor.

> Without an input schema, the users of our Actor will have to provide the input in JSON format, which can be problematic for those who are not familiar with JSON.
:::note JSON requirement

Without an input schema, the users of our Actor will have to provide the input in JSON format, which can be problematic for those who are not familiar with JSON.

:::

## Schema title & description {#title-and-description}

Expand Down Expand Up @@ -100,7 +104,7 @@ Here is what the input schema we wrote will render on the platform:

![Rendered UI from input schema](./images/rendered-ui.png)

Later on, we'll be building more complex input schemas, as well as discussing how to write quality input schemas that allow the user to understand the Actor and not become overwhelmed.
Later on, we'll be building more complex input schemas, as well as discussing how to write quality input schemas that allow the user to understand the Actor.

It's not expected to memorize all of the fields that properties can take or the different editor types available, which is why it's always good to reference the [input schema documentation](/platform/actors/development/actor-definition/input-schema) when writing a schema.

Expand Down
12 changes: 8 additions & 4 deletions sources/academy/platform/deploying_your_code/inputs_outputs.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
title: Managing Actor inputs and outputs
description: Learn to accept input into your Actor, do something with it, and then return output. Actors can be written in any language, so this concept is language agnostic.
description: Learn to accept input into your Actor, process it, and return output. This concept applies to Actors in any language.
sidebar_position: 1
slug: /deploying-your-code/inputs-outputs
---

**Learn to accept input into your Actor, do something with it, and then return output. Actors can be written in any language, so this concept is language agnostic.**
**Learn to accept input into your Actor, process it, and return output. This concept applies to Actors in any language.**

---

Most of the time when you're creating a project, you are expecting some sort of input from which your software will run off. Oftentimes as well, you want to provide some sort of output once your software has completed running. Apify provides a convenient way to handle inputs and deliver outputs.

An important thing to understand regarding inputs and outputs is that they are read/written differently depending on where the Actor is running:
Understanding inputs and outputs is essential because they are read/written differently depending on where the Actor is running:

- If your Actor is running locally, the inputs/outputs are usually provided in the filesystem, and environment variables are injected either by you, the developer, or by the Apify CLI by running the project with the `apify run` command.

Expand Down Expand Up @@ -160,7 +160,11 @@ await Actor.exit();

Just as with the custom `get_input()` utility function, you can write a custom `set_output()` function as well if you cannot use the Apify SDK.

> You can read and write your output anywhere; however, it is standard practice to use a folder named **storage**.
:::note Storage location

You can read and write your output anywhere; however, it is standard practice to use a folder named `storage`.

:::

```py
# index.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ const results = {

Great! Now that everything is set up, it's time to run the Actor and admire your Actor's brand new output tab.

> Need some extra guidance? Visit the [dataset schema documentation](/platform/actors/development/actor-definition/dataset-schema) for more detailed information about how to implement this feature.
:::tip Additional resources

Visit the [dataset schema documentation](/platform/actors/development/actor-definition/dataset-schema) for more detailed information about how to implement this feature.

:::

A few seconds after running the Actor, you should see its results displayed in the `Overview` table.

Expand Down
Loading