Instantly share code, notes, and snippets.

@jancurn /Dockerfile
Last active Sep 20, 2018

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

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

Just beware that whenever you edit the Gist, you'll need to rebuild the act.

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

act-in-gist-example.js

Contains the source code of the act in Node.js 8.

package.json

The file used by NPM to maintain meta-data 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 readme file is used to generate a long description of the act that is displayed in the Apify library as well as on the project's GitHub page.

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 act. 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://www.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", "act-in-gist-example.js" ]
{
"name": "act-in-gist-example",
"version": "0.0.1",
"private": true,
"dependencies": {
"apify": "^0.4.32"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment