Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of an Apify actor stored in a GitHub Gist.

This is an example of an Apify actor that is stored as GitHub Gist. Gists are useful if your actor has multiple source code files but you don't want to create a full Git repository for it or don't want to host your source files directly on Apify. All files of this Gist are provided under Apache 2.0 license.

Whenever you edit the Gist, you'll need to rebuild the actor.

Are you missing anything? Something not clear? Please let us know at support@apify.com

actor-in-gist-example.js

Contains the source code of the actor in Node.js.

package.json

The file used by NPM to maintain metadata about the package, such as list of dependencies. See NPM docs for more details.

Dockerfile

Contains instructions for Docker how to build the image for the act. For more information, see Dockerfile reference.

README.md

The Markup file is used to generate a long description of the actor that is displayed in Apify Library.

const Apify = require('apify');
Apify.main(async () => {
// Get act input
const input = await Apify.getValue('INPUT');
// Here's the place for your magic...
console.log('Hello world');
console.dir(input);
// Store the output
const output = {
message: 'Hello my friend!'
};
await Apify.setValue('OUTPUT', output)
});
# Here you choose the base Docker image for the actor. Apify provides the following images:
# apify/actor-node-basic
# apify/actor-node-chrome
# apify/actor-node-puppeteer
# However, you can use any other image from Docker Hub.
# For more information, see https://apify.com/docs/actor#base-images
FROM apify/actor-node-basic
# Copy all files and directories from the directory to the Docker image
COPY . ./
# Install NPM packages, skip optional and development dependencies to keep the image small,
# avoid logging to much and show log the dependency tree
RUN npm install --quiet --only=prod --no-optional \
&& npm list
# Define that start command
ENTRYPOINT [ "node", "actor-in-gist-example.js" ]
{
"name": "actor-in-gist-example",
"version": "0.0.1",
"private": true,
"dependencies": {
"apify": "^0.11.8"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.