Deploying your code to Apify
In this course learn how to take an existing project of yours and deploy it to the Apify platform as an actor in just a few minutes!
This section will discuss how to use your newfound knowledge of the Apify platform and actors from the Getting started section to deploy your existing project's code to the Apify platform as an actor.
Because actors are basically just chunks of code running in Docker containers, you're able to Actorify just about anything!
Actors are language agnostic, which means that the language your project is written in does not affect your ability to actorify it.
Though the majority of actors currently on the platform were written in Node.js, and despite the fact our current preferred languages are JavaScript and Python, there are a few examples of actors in other languages:
The "actorification" workflow
There are four main steps to turning a piece of code into an actor:
- Handle accepting inputs and writing outputs.
- Create an input schema (optional).
- Add a Dockerfile.
- Deploy to the Apify platform!
Our example project
For this section, we'll be turning this example project into an actor:
- JavaScript
- Python
// index.js
const addAllNumbers = (...nums) => nums.reduce((total, curr) => (total += curr));
console.log(addAllNumbers(1, 2, 3, 4)) // -> 10
# index.py
def add_all_numbers (nums):
total = 0
for num in nums:
total += num
return total
print(add_all_numbers([1, 2, 3, 4])) # -> 10
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.
Next up
Next lesson, we'll be learning how to accept input into our actor as well as deliver output.